@univerjs/docs-ui 1.0.0-alpha.7 → 1.0.0-alpha.8
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 +747 -371
- package/lib/cjs/locale/ar-SA.js +39 -26
- package/lib/cjs/locale/ca-ES.js +39 -26
- package/lib/cjs/locale/de-DE.js +39 -26
- package/lib/cjs/locale/en-US.js +14 -1
- package/lib/cjs/locale/es-ES.js +39 -26
- package/lib/cjs/locale/fa-IR.js +41 -28
- package/lib/cjs/locale/fr-FR.js +42 -29
- package/lib/cjs/locale/id-ID.js +39 -26
- package/lib/cjs/locale/it-IT.js +39 -26
- package/lib/cjs/locale/ja-JP.js +39 -26
- package/lib/cjs/locale/ko-KR.js +39 -26
- package/lib/cjs/locale/pl-PL.js +38 -25
- package/lib/cjs/locale/pt-BR.js +39 -26
- package/lib/cjs/locale/ru-RU.js +39 -26
- package/lib/cjs/locale/sk-SK.js +39 -26
- package/lib/cjs/locale/vi-VN.js +60 -47
- package/lib/cjs/locale/zh-CN.js +14 -1
- package/lib/cjs/locale/zh-HK.js +66 -53
- package/lib/cjs/locale/zh-TW.js +48 -35
- package/lib/es/index.js +750 -329
- package/lib/es/locale/ar-SA.js +39 -26
- package/lib/es/locale/ca-ES.js +39 -26
- package/lib/es/locale/de-DE.js +39 -26
- package/lib/es/locale/en-US.js +14 -1
- package/lib/es/locale/es-ES.js +39 -26
- package/lib/es/locale/fa-IR.js +41 -28
- package/lib/es/locale/fr-FR.js +42 -29
- package/lib/es/locale/id-ID.js +39 -26
- package/lib/es/locale/it-IT.js +39 -26
- package/lib/es/locale/ja-JP.js +39 -26
- package/lib/es/locale/ko-KR.js +39 -26
- package/lib/es/locale/pl-PL.js +38 -25
- package/lib/es/locale/pt-BR.js +39 -26
- package/lib/es/locale/ru-RU.js +39 -26
- package/lib/es/locale/sk-SK.js +39 -26
- package/lib/es/locale/vi-VN.js +60 -47
- package/lib/es/locale/zh-CN.js +14 -1
- package/lib/es/locale/zh-HK.js +66 -53
- package/lib/es/locale/zh-TW.js +48 -35
- package/lib/index.css +4 -0
- package/lib/index.js +750 -329
- package/lib/locale/ar-SA.js +39 -26
- package/lib/locale/ca-ES.js +39 -26
- package/lib/locale/de-DE.js +39 -26
- package/lib/locale/en-US.js +14 -1
- package/lib/locale/es-ES.js +39 -26
- package/lib/locale/fa-IR.js +41 -28
- package/lib/locale/fr-FR.js +42 -29
- package/lib/locale/id-ID.js +39 -26
- package/lib/locale/it-IT.js +39 -26
- package/lib/locale/ja-JP.js +39 -26
- package/lib/locale/ko-KR.js +39 -26
- package/lib/locale/pl-PL.js +38 -25
- package/lib/locale/pt-BR.js +39 -26
- package/lib/locale/ru-RU.js +39 -26
- package/lib/locale/sk-SK.js +39 -26
- package/lib/locale/vi-VN.js +60 -47
- package/lib/locale/zh-CN.js +14 -1
- package/lib/locale/zh-HK.js +66 -53
- package/lib/locale/zh-TW.js +48 -35
- package/lib/types/basics/component-tools.d.ts +3 -5
- package/lib/types/basics/doc-custom-range-chrome.d.ts +31 -0
- package/lib/types/commands/commands/clipboard.inner.command.d.ts +2 -0
- package/lib/types/commands/commands/replace-content.command.d.ts +10 -14
- package/lib/types/commands/operations/insert-break.operation.d.ts +21 -0
- package/lib/types/controllers/doc-move-cursor.controller.d.ts +0 -1
- package/lib/types/controllers/doc-section-setting.controller.d.ts +4 -1
- package/lib/types/controllers/render-controllers/doc-paragraph-placeholder.render-controller.d.ts +11 -2
- package/lib/types/index.d.ts +10 -10
- package/lib/types/locale/en-US.d.ts +13 -0
- package/lib/types/menu/menu.d.ts +13 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +11 -2
- package/lib/types/services/clipboard/doc-paste-mutation-adapter.service.d.ts +6 -1
- package/lib/types/services/editor/editor-manager.service.d.ts +1 -0
- package/lib/types/services/editor/editor.d.ts +7 -26
- package/lib/types/services/selection/doc-selection-render.service.d.ts +0 -3
- package/lib/types/views/paragraph-setting/hook/utils.d.ts +2 -0
- package/lib/types/views/rich-text-editor/hooks/use-keyboard-event.d.ts +2 -1
- package/lib/types/views/section-setting/use-section-setting.d.ts +33 -2
- package/lib/umd/index.js +11 -10
- 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 +9 -9
package/lib/cjs/index.js
CHANGED
|
@@ -55,23 +55,8 @@ function neoGetDocObject(renderContext) {
|
|
|
55
55
|
engine
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
/** @deprecated After migrating to `RenderUnit`, use `neoGetDocObject` instead. */
|
|
59
|
-
function getDocObject(univerInstanceService, renderManagerService) {
|
|
60
|
-
const documentModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
61
|
-
if (!documentModel) return null;
|
|
62
|
-
const unitId = documentModel.getUnitId();
|
|
63
|
-
const currentRender = renderManagerService.getRenderById(unitId);
|
|
64
|
-
if (currentRender == null) return;
|
|
65
|
-
const { mainComponent, scene, engine, components } = currentRender;
|
|
66
|
-
return {
|
|
67
|
-
document: mainComponent,
|
|
68
|
-
docBackground: components.get("__Document_Render_Background__"),
|
|
69
|
-
scene,
|
|
70
|
-
engine
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
58
|
function getDocObjectById(unitId, renderManagerService) {
|
|
74
|
-
const currentRender = renderManagerService.
|
|
59
|
+
const currentRender = renderManagerService.getRenderUnitById(unitId);
|
|
75
60
|
if (currentRender == null) return;
|
|
76
61
|
const { mainComponent, scene, engine, components } = currentRender;
|
|
77
62
|
return {
|
|
@@ -149,6 +134,29 @@ function deleteCustomDecorationFactory(accessor, params) {
|
|
|
149
134
|
return doMutation;
|
|
150
135
|
}
|
|
151
136
|
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/basics/doc-custom-range-chrome.ts
|
|
139
|
+
const DOC_CUSTOM_RANGE_CHROME_RADIUS = 1;
|
|
140
|
+
const DOC_CUSTOM_RANGE_CHROME_BACKGROUND_ALPHA = .07;
|
|
141
|
+
function resolveDocCustomRangeChromeTheme(themeService) {
|
|
142
|
+
const primary = themeService.getColorFromTheme("primary.600");
|
|
143
|
+
return {
|
|
144
|
+
background: new _univerjs_core.ColorKit(primary).setAlpha(DOC_CUSTOM_RANGE_CHROME_BACKGROUND_ALPHA).toRgbString(),
|
|
145
|
+
border: primary
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function drawDocCustomRangeChrome(ctx, rect, theme) {
|
|
149
|
+
ctx.save();
|
|
150
|
+
ctx.fillStyle = theme.background;
|
|
151
|
+
ctx.strokeStyle = theme.border;
|
|
152
|
+
ctx.lineWidth = 1;
|
|
153
|
+
ctx.beginPath();
|
|
154
|
+
ctx.roundRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 1);
|
|
155
|
+
ctx.fill();
|
|
156
|
+
ctx.stroke();
|
|
157
|
+
ctx.restore();
|
|
158
|
+
}
|
|
159
|
+
|
|
152
160
|
//#endregion
|
|
153
161
|
//#region src/basics/paragraph.ts
|
|
154
162
|
function isTopLevelStructuralGap(dataStream, offset) {
|
|
@@ -206,7 +214,7 @@ function getCustomDecorationAtPosition(customDecorations, position) {
|
|
|
206
214
|
}
|
|
207
215
|
|
|
208
216
|
//#endregion
|
|
209
|
-
//#region \0@oxc-project+runtime@0.
|
|
217
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
210
218
|
function _typeof(o) {
|
|
211
219
|
"@babel/helpers - typeof";
|
|
212
220
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -217,7 +225,7 @@ function _typeof(o) {
|
|
|
217
225
|
}
|
|
218
226
|
|
|
219
227
|
//#endregion
|
|
220
|
-
//#region \0@oxc-project+runtime@0.
|
|
228
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
221
229
|
function toPrimitive(t, r) {
|
|
222
230
|
if ("object" != _typeof(t) || !t) return t;
|
|
223
231
|
var e = t[Symbol.toPrimitive];
|
|
@@ -230,14 +238,14 @@ function toPrimitive(t, r) {
|
|
|
230
238
|
}
|
|
231
239
|
|
|
232
240
|
//#endregion
|
|
233
|
-
//#region \0@oxc-project+runtime@0.
|
|
241
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
234
242
|
function toPropertyKey(t) {
|
|
235
243
|
var i = toPrimitive(t, "string");
|
|
236
244
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
237
245
|
}
|
|
238
246
|
|
|
239
247
|
//#endregion
|
|
240
|
-
//#region \0@oxc-project+runtime@0.
|
|
248
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
241
249
|
function _defineProperty(e, r, t) {
|
|
242
250
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
243
251
|
value: t,
|
|
@@ -248,7 +256,7 @@ function _defineProperty(e, r, t) {
|
|
|
248
256
|
}
|
|
249
257
|
|
|
250
258
|
//#endregion
|
|
251
|
-
//#region \0@oxc-project+runtime@0.
|
|
259
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
252
260
|
function __decorateParam(paramIndex, decorator) {
|
|
253
261
|
return function(target, key) {
|
|
254
262
|
decorator(target, key, paramIndex);
|
|
@@ -256,7 +264,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
256
264
|
}
|
|
257
265
|
|
|
258
266
|
//#endregion
|
|
259
|
-
//#region \0@oxc-project+runtime@0.
|
|
267
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
260
268
|
function __decorate(decorators, target, key, desc) {
|
|
261
269
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
262
270
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -381,7 +389,7 @@ let DocMenuStyleService = class DocMenuStyleService extends _univerjs_core.Dispo
|
|
|
381
389
|
const docDataModel = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
382
390
|
if (docDataModel == null) return { ...DEFAULT_TEXT_STYLE };
|
|
383
391
|
const unitId = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId();
|
|
384
|
-
const docSkeletonManagerService = (_this$_renderManagerS = this._renderManagerService.
|
|
392
|
+
const docSkeletonManagerService = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_docs.DocSkeletonManagerService);
|
|
385
393
|
const docViewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
386
394
|
if (docViewModel == null) return { ...DEFAULT_TEXT_STYLE };
|
|
387
395
|
if (docViewModel.getEditArea() === _univerjs_engine_render.DocumentEditArea.BODY) return { ...DEFAULT_TEXT_STYLE };
|
|
@@ -569,7 +577,7 @@ var DocClipboardPasteAdapterService = class {
|
|
|
569
577
|
*/
|
|
570
578
|
function getCommandSkeleton(accessor, unitId) {
|
|
571
579
|
var _renderManagerService;
|
|
572
|
-
return (_renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService).
|
|
580
|
+
return (_renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService);
|
|
573
581
|
}
|
|
574
582
|
|
|
575
583
|
//#endregion
|
|
@@ -1083,7 +1091,7 @@ const InnerPasteCommand = {
|
|
|
1083
1091
|
type: _univerjs_core.CommandType.COMMAND,
|
|
1084
1092
|
handler: async (accessor, params) => {
|
|
1085
1093
|
var _docDataModel$getSelf, _body$tables, _body$customBlocks, _body$blockRanges;
|
|
1086
|
-
const { segmentId, textRanges, doc } = params;
|
|
1094
|
+
const { customRangeMappings = [], segmentId, textRanges, doc } = params;
|
|
1087
1095
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
1088
1096
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
1089
1097
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
@@ -1128,6 +1136,11 @@ const InnerPasteCommand = {
|
|
|
1128
1136
|
const cloneBody = _univerjs_core.Tools.deepClone(body);
|
|
1129
1137
|
const blockRangeMappings = [];
|
|
1130
1138
|
const customBlockMappings = [];
|
|
1139
|
+
const selectionCustomRangeMappings = customRangeMappings.map(({ sourceRange }) => ({
|
|
1140
|
+
sourceRange,
|
|
1141
|
+
targetRange: _univerjs_core.BuildTextUtils.customRange.copyCustomRange(sourceRange)
|
|
1142
|
+
}));
|
|
1143
|
+
if (selectionCustomRangeMappings.length > 0) cloneBody.customRanges = selectionCustomRangeMappings.map(({ targetRange }) => targetRange);
|
|
1131
1144
|
if (hasBlockRange) cloneBody.blockRanges.forEach((targetBlockRange, index) => {
|
|
1132
1145
|
const sourceBlockRange = body.blockRanges[index];
|
|
1133
1146
|
targetBlockRange.blockId = (0, _univerjs_core.generateRandomId)(6);
|
|
@@ -1169,7 +1182,7 @@ const InnerPasteCommand = {
|
|
|
1169
1182
|
rawActions.push(orderAction);
|
|
1170
1183
|
});
|
|
1171
1184
|
}
|
|
1172
|
-
if ((blockRangeMappings.length > 0 || customBlockMappings.length > 0) && pasteAdapterService) {
|
|
1185
|
+
if ((blockRangeMappings.length > 0 || customBlockMappings.length > 0 || selectionCustomRangeMappings.length > 0) && pasteAdapterService) {
|
|
1173
1186
|
const mutationInfos = pasteAdapterService.getPasteMutationInfos({
|
|
1174
1187
|
unitId,
|
|
1175
1188
|
segmentId,
|
|
@@ -1177,6 +1190,7 @@ const InnerPasteCommand = {
|
|
|
1177
1190
|
sourceBody: body,
|
|
1178
1191
|
targetBody: cloneBody,
|
|
1179
1192
|
blockRangeMappings,
|
|
1193
|
+
customRangeMappings: selectionCustomRangeMappings,
|
|
1180
1194
|
customBlockMappings
|
|
1181
1195
|
});
|
|
1182
1196
|
if (mutationInfos.redoMutations.length > 0 || mutationInfos.undoMutations.length > 0) {
|
|
@@ -3747,12 +3761,12 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3747
3761
|
}
|
|
3748
3762
|
async copy(sliceType = _univerjs_core.SliceBodyType.copy, ranges) {
|
|
3749
3763
|
var _this$_getDocumentBod;
|
|
3750
|
-
const { newSnapshotList = [], needCache = false, snapshot, ranges: allRanges } = (_this$_getDocumentBod = this._getDocumentBodyInRanges(sliceType, ranges)) !== null && _this$_getDocumentBod !== void 0 ? _this$_getDocumentBod : {};
|
|
3764
|
+
const { newSnapshotList = [], needCache = false, plainTextList, snapshot, ranges: allRanges } = (_this$_getDocumentBod = this._getDocumentBodyInRanges(sliceType, ranges)) !== null && _this$_getDocumentBod !== void 0 ? _this$_getDocumentBod : {};
|
|
3751
3765
|
if (newSnapshotList.length === 0 || snapshot == null) return false;
|
|
3752
3766
|
try {
|
|
3753
3767
|
var _allRanges$;
|
|
3754
3768
|
const isCopyInHeaderFooter = !!(allRanges === null || allRanges === void 0 || (_allRanges$ = allRanges[0]) === null || _allRanges$ === void 0 ? void 0 : _allRanges$.segmentId);
|
|
3755
|
-
await this._setClipboardData(newSnapshotList, !isCopyInHeaderFooter && needCache);
|
|
3769
|
+
await this._setClipboardData(newSnapshotList, !isCopyInHeaderFooter && needCache, plainTextList);
|
|
3756
3770
|
} catch (e) {
|
|
3757
3771
|
this._logService.error("[DocClipboardService] copy failed", e);
|
|
3758
3772
|
return false;
|
|
@@ -3821,16 +3835,25 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3821
3835
|
}
|
|
3822
3836
|
}
|
|
3823
3837
|
async _paste(docData) {
|
|
3824
|
-
var _body$customRanges, _body$paragraphs, _currentDocument$getS;
|
|
3838
|
+
var _body$customRanges$ma, _body$customRanges, _body$paragraphs, _currentDocument$getS;
|
|
3825
3839
|
const { body: _body } = docData;
|
|
3826
3840
|
if (_body == null) return false;
|
|
3827
3841
|
let body = (0, _univerjs_core.normalizeBody)(_body);
|
|
3828
3842
|
const currentDocument = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
3829
3843
|
if (!currentDocument) return false;
|
|
3830
3844
|
this._clipboardHooks.forEach((hook) => {
|
|
3831
|
-
if (hook.onBeforePaste) body = hook.onBeforePaste(body
|
|
3845
|
+
if (hook.onBeforePaste) body = hook.onBeforePaste(body, {
|
|
3846
|
+
documentData: docData,
|
|
3847
|
+
targetUnitId: currentDocument.getUnitId()
|
|
3848
|
+
});
|
|
3832
3849
|
});
|
|
3833
|
-
|
|
3850
|
+
const customRangeMappings = (_body$customRanges$ma = (_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.map((sourceRange) => {
|
|
3851
|
+
return {
|
|
3852
|
+
sourceRange,
|
|
3853
|
+
targetRange: _univerjs_core.BuildTextUtils.customRange.copyCustomRange(sourceRange)
|
|
3854
|
+
};
|
|
3855
|
+
})) !== null && _body$customRanges$ma !== void 0 ? _body$customRanges$ma : [];
|
|
3856
|
+
body.customRanges = customRangeMappings.map(({ targetRange }) => targetRange);
|
|
3834
3857
|
(_body$paragraphs = body.paragraphs) === null || _body$paragraphs === void 0 || _body$paragraphs.forEach((copy) => {
|
|
3835
3858
|
var _copy$paragraphStyle;
|
|
3836
3859
|
if ((_copy$paragraphStyle = copy.paragraphStyle) === null || _copy$paragraphStyle === void 0 ? void 0 : _copy$paragraphStyle.headingId) copy.paragraphStyle.headingId = (0, _univerjs_core.generateRandomId)(6);
|
|
@@ -3858,6 +3881,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3858
3881
|
...docData,
|
|
3859
3882
|
body
|
|
3860
3883
|
},
|
|
3884
|
+
customRangeMappings,
|
|
3861
3885
|
segmentId,
|
|
3862
3886
|
textRanges
|
|
3863
3887
|
});
|
|
@@ -3866,10 +3890,10 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3866
3890
|
return false;
|
|
3867
3891
|
}
|
|
3868
3892
|
}
|
|
3869
|
-
async _setClipboardData(documentList, needCache = true) {
|
|
3893
|
+
async _setClipboardData(documentList, needCache = true, plainTextList) {
|
|
3870
3894
|
var _documentList$0$body;
|
|
3871
3895
|
const copyId = (0, _univerjs_core.generateRandomId)(6);
|
|
3872
|
-
const text = (documentList.length > 1 ? documentList.map((doc) => {
|
|
3896
|
+
const text = (plainTextList ? plainTextList.join("\n") : documentList.length > 1 ? documentList.map((doc) => {
|
|
3873
3897
|
var _doc$body;
|
|
3874
3898
|
return ((_doc$body = doc.body) === null || _doc$body === void 0 ? void 0 : _doc$body.dataStream) || "";
|
|
3875
3899
|
}).join("\n") : ((_documentList$0$body = documentList[0].body) === null || _documentList$0$body === void 0 ? void 0 : _documentList$0$body.dataStream) || "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_ROW_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_ROW_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.BLOCK_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.BLOCK_END, "").replaceAll("\r\n", " ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "");
|
|
@@ -3906,10 +3930,12 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3906
3930
|
}, doc);
|
|
3907
3931
|
}
|
|
3908
3932
|
_getDocumentBodyInRanges(sliceType, ranges) {
|
|
3909
|
-
var _docDataModel$getSelf;
|
|
3933
|
+
var _this$_clipboardHooks, _docDataModel$getSelf;
|
|
3910
3934
|
const docDataModel = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
3911
3935
|
const allRanges = ranges !== null && ranges !== void 0 ? ranges : this._docSelectionManagerService.getDocRanges();
|
|
3912
3936
|
const results = [];
|
|
3937
|
+
const plainTextResults = [];
|
|
3938
|
+
const copyContentHook = (_this$_clipboardHooks = this._clipboardHooks.find((hook) => hook.onCopyContent)) === null || _this$_clipboardHooks === void 0 ? void 0 : _this$_clipboardHooks.onCopyContent;
|
|
3913
3939
|
let needCache = true;
|
|
3914
3940
|
if (docDataModel == null || allRanges.length === 0) return;
|
|
3915
3941
|
const segmentId = allRanges[0].segmentId;
|
|
@@ -3917,13 +3943,14 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3917
3943
|
const snapshot = docDataModel.getSnapshot();
|
|
3918
3944
|
if (body == null) return;
|
|
3919
3945
|
for (const range of allRanges) {
|
|
3920
|
-
var _docDataModel$getSelf2;
|
|
3946
|
+
var _docDataModel$getSelf2, _copyContentHook;
|
|
3921
3947
|
const { startOffset, endOffset, collapsed, rangeType } = range;
|
|
3922
3948
|
if (collapsed || startOffset == null || endOffset == null) continue;
|
|
3923
3949
|
if (rangeType === _univerjs_core.DOC_RANGE_TYPE.RECT) {
|
|
3924
3950
|
needCache = false;
|
|
3925
3951
|
const bodySlice = getTableClipboardBodySlice(body, range);
|
|
3926
3952
|
results.push(bodySlice);
|
|
3953
|
+
plainTextResults.push(bodySlice.dataStream);
|
|
3927
3954
|
continue;
|
|
3928
3955
|
}
|
|
3929
3956
|
const deleteRange = {
|
|
@@ -3934,6 +3961,11 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3934
3961
|
const docBody = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.sliceBody(deleteRange.startOffset, deleteRange.endOffset, sliceType);
|
|
3935
3962
|
if (docBody == null) continue;
|
|
3936
3963
|
results.push(docBody);
|
|
3964
|
+
plainTextResults.push((_copyContentHook = copyContentHook === null || copyContentHook === void 0 ? void 0 : copyContentHook(deleteRange.startOffset, deleteRange.endOffset, {
|
|
3965
|
+
body,
|
|
3966
|
+
segmentId,
|
|
3967
|
+
unitId: docDataModel.getUnitId()
|
|
3968
|
+
})) !== null && _copyContentHook !== void 0 ? _copyContentHook : docBody.dataStream);
|
|
3937
3969
|
}
|
|
3938
3970
|
return {
|
|
3939
3971
|
newSnapshotList: results.map((e) => ({
|
|
@@ -3941,6 +3973,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3941
3973
|
body: e
|
|
3942
3974
|
})),
|
|
3943
3975
|
needCache,
|
|
3976
|
+
plainTextList: plainTextResults,
|
|
3944
3977
|
snapshot,
|
|
3945
3978
|
ranges: allRanges
|
|
3946
3979
|
};
|
|
@@ -3999,16 +4032,17 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3999
4032
|
return doc;
|
|
4000
4033
|
}
|
|
4001
4034
|
async _uploadBase64ImagesInHtml(html) {
|
|
4002
|
-
var _this$
|
|
4035
|
+
var _this$_clipboardHooks2;
|
|
4003
4036
|
if (!html || !html.includes("data:image/")) return html;
|
|
4004
|
-
const onBeforePasteImage = (_this$
|
|
4037
|
+
const onBeforePasteImage = (_this$_clipboardHooks2 = this._clipboardHooks.find((e) => e.onBeforePasteImage)) === null || _this$_clipboardHooks2 === void 0 ? void 0 : _this$_clipboardHooks2.onBeforePasteImage;
|
|
4005
4038
|
if (!onBeforePasteImage) return html;
|
|
4006
4039
|
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
4007
4040
|
const images = Array.from(doc.querySelectorAll("img[src^=\"data:image/\"]"));
|
|
4008
4041
|
if (images.length === 0) return html;
|
|
4009
4042
|
await Promise.all(images.map(async (image, index) => {
|
|
4010
4043
|
if (image.dataset.imageSourceType && image.dataset.imageSourceType !== _univerjs_core.ImageSourceType.BASE64) return;
|
|
4011
|
-
const
|
|
4044
|
+
const file = dataUrlToFile(image.getAttribute("src") || image.src, `pasted_image_${index}`);
|
|
4045
|
+
const uploaded = await onBeforePasteImage(file);
|
|
4012
4046
|
if (!uploaded) return;
|
|
4013
4047
|
image.dataset.imageSourceType = uploaded.imageSourceType;
|
|
4014
4048
|
if (uploaded.imageSourceType === _univerjs_core.ImageSourceType.UUID) {
|
|
@@ -4022,7 +4056,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
4022
4056
|
return doc.documentElement.outerHTML;
|
|
4023
4057
|
}
|
|
4024
4058
|
async _createImagePasteHtml(files) {
|
|
4025
|
-
var _this$
|
|
4059
|
+
var _this$_clipboardHooks3, _this$_clipboardHooks4;
|
|
4026
4060
|
const doc = {
|
|
4027
4061
|
id: "",
|
|
4028
4062
|
documentStyle: {},
|
|
@@ -4058,7 +4092,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
4058
4092
|
};
|
|
4059
4093
|
});
|
|
4060
4094
|
};
|
|
4061
|
-
const onBeforePasteImage = (_this$
|
|
4095
|
+
const onBeforePasteImage = (_this$_clipboardHooks3 = (_this$_clipboardHooks4 = this._clipboardHooks.find((e) => e.onBeforePasteImage)) === null || _this$_clipboardHooks4 === void 0 ? void 0 : _this$_clipboardHooks4.onBeforePasteImage) !== null && _this$_clipboardHooks3 !== void 0 ? _this$_clipboardHooks3 : fileToBase64;
|
|
4062
4096
|
await Promise.all(files.map(async (file, index) => {
|
|
4063
4097
|
var _body$customBlocks;
|
|
4064
4098
|
const image = await onBeforePasteImage(file);
|
|
@@ -4802,7 +4836,7 @@ const IMEInputCommand = {
|
|
|
4802
4836
|
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
4803
4837
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
4804
4838
|
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
4805
|
-
const imeInputManagerService = (_renderManagerService = renderManagerService.
|
|
4839
|
+
const imeInputManagerService = (_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(DocIMEInputManagerService);
|
|
4806
4840
|
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
4807
4841
|
if (docDataModel == null || imeInputManagerService == null) return false;
|
|
4808
4842
|
const previousActiveRange = imeInputManagerService.getActiveRange();
|
|
@@ -4895,7 +4929,8 @@ const SetInlineFormatBoldCommand = {
|
|
|
4895
4929
|
id: SetInlineFormatBoldCommandId,
|
|
4896
4930
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4897
4931
|
handler: async (accessor, params) => {
|
|
4898
|
-
|
|
4932
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4933
|
+
return handleInlineFormat(SetInlineFormatBoldCommandId, params, commandService);
|
|
4899
4934
|
}
|
|
4900
4935
|
};
|
|
4901
4936
|
const SetInlineFormatItalicCommandId = "doc.command.set-inline-format-italic";
|
|
@@ -4903,7 +4938,8 @@ const SetInlineFormatItalicCommand = {
|
|
|
4903
4938
|
id: SetInlineFormatItalicCommandId,
|
|
4904
4939
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4905
4940
|
handler: async (accessor, params) => {
|
|
4906
|
-
|
|
4941
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4942
|
+
return handleInlineFormat(SetInlineFormatItalicCommandId, params, commandService);
|
|
4907
4943
|
}
|
|
4908
4944
|
};
|
|
4909
4945
|
const SetInlineFormatUnderlineCommandId = "doc.command.set-inline-format-underline";
|
|
@@ -4911,7 +4947,8 @@ const SetInlineFormatUnderlineCommand = {
|
|
|
4911
4947
|
id: SetInlineFormatUnderlineCommandId,
|
|
4912
4948
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4913
4949
|
handler: async (accessor, params) => {
|
|
4914
|
-
|
|
4950
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4951
|
+
return handleInlineFormat(SetInlineFormatUnderlineCommandId, params, commandService);
|
|
4915
4952
|
}
|
|
4916
4953
|
};
|
|
4917
4954
|
const SetInlineFormatStrikethroughCommandId = "doc.command.set-inline-format-strikethrough";
|
|
@@ -4919,7 +4956,8 @@ const SetInlineFormatStrikethroughCommand = {
|
|
|
4919
4956
|
id: SetInlineFormatStrikethroughCommandId,
|
|
4920
4957
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4921
4958
|
handler: async (accessor, params) => {
|
|
4922
|
-
|
|
4959
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4960
|
+
return handleInlineFormat(SetInlineFormatStrikethroughCommandId, params, commandService);
|
|
4923
4961
|
}
|
|
4924
4962
|
};
|
|
4925
4963
|
const SetInlineFormatSubscriptCommandId = "doc.command.set-inline-format-subscript";
|
|
@@ -4927,7 +4965,8 @@ const SetInlineFormatSubscriptCommand = {
|
|
|
4927
4965
|
id: SetInlineFormatSubscriptCommandId,
|
|
4928
4966
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4929
4967
|
handler: async (accessor, params) => {
|
|
4930
|
-
|
|
4968
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4969
|
+
return handleInlineFormat(SetInlineFormatSubscriptCommandId, params, commandService);
|
|
4931
4970
|
}
|
|
4932
4971
|
};
|
|
4933
4972
|
const SetInlineFormatSuperscriptCommandId = "doc.command.set-inline-format-superscript";
|
|
@@ -4935,7 +4974,8 @@ const SetInlineFormatSuperscriptCommand = {
|
|
|
4935
4974
|
id: SetInlineFormatSuperscriptCommandId,
|
|
4936
4975
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4937
4976
|
handler: async (accessor, params) => {
|
|
4938
|
-
|
|
4977
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4978
|
+
return handleInlineFormat(SetInlineFormatSuperscriptCommandId, params, commandService);
|
|
4939
4979
|
}
|
|
4940
4980
|
};
|
|
4941
4981
|
const SetInlineFormatFontSizeCommandId = "doc.command.set-inline-format-fontsize";
|
|
@@ -4943,7 +4983,8 @@ const SetInlineFormatFontSizeCommand = {
|
|
|
4943
4983
|
id: SetInlineFormatFontSizeCommandId,
|
|
4944
4984
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4945
4985
|
handler: async (accessor, params) => {
|
|
4946
|
-
|
|
4986
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4987
|
+
return handleInlineFormat(SetInlineFormatFontSizeCommandId, params, commandService);
|
|
4947
4988
|
}
|
|
4948
4989
|
};
|
|
4949
4990
|
const SetInlineFormatFontFamilyCommandId = "doc.command.set-inline-format-font-family";
|
|
@@ -4951,7 +4992,8 @@ const SetInlineFormatFontFamilyCommand = {
|
|
|
4951
4992
|
id: SetInlineFormatFontFamilyCommandId,
|
|
4952
4993
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4953
4994
|
handler: async (accessor, params) => {
|
|
4954
|
-
|
|
4995
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4996
|
+
return handleInlineFormat(SetInlineFormatFontFamilyCommandId, params, commandService);
|
|
4955
4997
|
}
|
|
4956
4998
|
};
|
|
4957
4999
|
const SetInlineFormatTextColorCommandId = "doc.command.set-inline-format-text-color";
|
|
@@ -4959,7 +5001,8 @@ const SetInlineFormatTextColorCommand = {
|
|
|
4959
5001
|
id: SetInlineFormatTextColorCommandId,
|
|
4960
5002
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4961
5003
|
handler: async (accessor, params) => {
|
|
4962
|
-
|
|
5004
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5005
|
+
return handleInlineFormat(SetInlineFormatTextColorCommandId, params, commandService);
|
|
4963
5006
|
}
|
|
4964
5007
|
};
|
|
4965
5008
|
const ResetInlineFormatTextColorCommandId = "doc.command.reset-inline-format-text-color";
|
|
@@ -4967,7 +5010,8 @@ const ResetInlineFormatTextColorCommand = {
|
|
|
4967
5010
|
id: ResetInlineFormatTextColorCommandId,
|
|
4968
5011
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4969
5012
|
handler: async (accessor, params) => {
|
|
4970
|
-
|
|
5013
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5014
|
+
return handleInlineFormat(ResetInlineFormatTextColorCommandId, params, commandService);
|
|
4971
5015
|
}
|
|
4972
5016
|
};
|
|
4973
5017
|
const SetInlineFormatTextFillCommandId = "doc.command.set-inline-format-text-fill";
|
|
@@ -4975,7 +5019,8 @@ const SetInlineFormatTextFillCommand = {
|
|
|
4975
5019
|
id: SetInlineFormatTextFillCommandId,
|
|
4976
5020
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4977
5021
|
handler: async (accessor, params) => {
|
|
4978
|
-
|
|
5022
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5023
|
+
return handleInlineFormat(SetInlineFormatTextFillCommandId, params, commandService);
|
|
4979
5024
|
}
|
|
4980
5025
|
};
|
|
4981
5026
|
const SetInlineFormatTextBackgroundColorCommandId = "doc.command.set-inline-format-text-background-color";
|
|
@@ -4983,7 +5028,8 @@ const SetInlineFormatTextBackgroundColorCommand = {
|
|
|
4983
5028
|
id: SetInlineFormatTextBackgroundColorCommandId,
|
|
4984
5029
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4985
5030
|
handler: async (accessor, params) => {
|
|
4986
|
-
|
|
5031
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5032
|
+
return handleInlineFormat(SetInlineFormatTextBackgroundColorCommandId, params, commandService);
|
|
4987
5033
|
}
|
|
4988
5034
|
};
|
|
4989
5035
|
const ResetInlineFormatTextBackgroundColorCommandId = "doc.command.reset-inline-format-text-background-color";
|
|
@@ -4991,7 +5037,8 @@ const ResetInlineFormatTextBackgroundColorCommand = {
|
|
|
4991
5037
|
id: ResetInlineFormatTextBackgroundColorCommandId,
|
|
4992
5038
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4993
5039
|
handler: async (accessor, params) => {
|
|
4994
|
-
|
|
5040
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5041
|
+
return handleInlineFormat(ResetInlineFormatTextBackgroundColorCommandId, params, commandService);
|
|
4995
5042
|
}
|
|
4996
5043
|
};
|
|
4997
5044
|
const COMMAND_ID_TO_FORMAT_KEY_MAP = {
|
|
@@ -5289,35 +5336,6 @@ function collectTopLevelReplaceAction(jsonX, rawActions, path, previousValue, va
|
|
|
5289
5336
|
const action = jsonX.replaceOp(path, previousValue, value);
|
|
5290
5337
|
if (action != null) rawActions.push(action);
|
|
5291
5338
|
}
|
|
5292
|
-
/**
|
|
5293
|
-
* @deprecated please use ReplaceSnapshotCommand instead.
|
|
5294
|
-
*/
|
|
5295
|
-
const ReplaceContentCommand = {
|
|
5296
|
-
id: "doc.command-replace-content",
|
|
5297
|
-
type: _univerjs_core.CommandType.COMMAND,
|
|
5298
|
-
handler: async (accessor, params) => {
|
|
5299
|
-
var _docDataModel$getSelf2;
|
|
5300
|
-
const { unitId, body, textRanges, segmentId = "", options } = params;
|
|
5301
|
-
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
5302
|
-
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5303
|
-
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
5304
|
-
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
5305
|
-
const prevBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
|
|
5306
|
-
if (docDataModel == null || prevBody == null) return false;
|
|
5307
|
-
const doMutation = getMutationParams(unitId, segmentId, docDataModel, prevBody, body);
|
|
5308
|
-
doMutation.params.textRanges = textRanges;
|
|
5309
|
-
if (options) doMutation.params.options = options;
|
|
5310
|
-
if (doMutation.params.actions == null && textRanges) {
|
|
5311
|
-
docSelectionManagerService.replaceDocRanges(textRanges, {
|
|
5312
|
-
unitId,
|
|
5313
|
-
subUnitId: unitId
|
|
5314
|
-
}, false);
|
|
5315
|
-
return true;
|
|
5316
|
-
}
|
|
5317
|
-
const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
5318
|
-
return Boolean(result);
|
|
5319
|
-
}
|
|
5320
|
-
};
|
|
5321
5339
|
const CoverContentCommand = {
|
|
5322
5340
|
id: "doc.command-cover-content",
|
|
5323
5341
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -5401,13 +5419,13 @@ const ReplaceTextRunsCommand = {
|
|
|
5401
5419
|
id: "doc.command.replace-text-runs",
|
|
5402
5420
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5403
5421
|
handler: (accessor, params) => {
|
|
5404
|
-
var _docDataModel$
|
|
5422
|
+
var _docDataModel$getSelf2;
|
|
5405
5423
|
const { unitId, body, textRanges, segmentId = "", options } = params;
|
|
5406
5424
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
5407
5425
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5408
5426
|
const themeService = accessor.get(_univerjs_core.ThemeService);
|
|
5409
5427
|
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
5410
|
-
const prevBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$
|
|
5428
|
+
const prevBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
|
|
5411
5429
|
if (docDataModel == null || prevBody == null) return false;
|
|
5412
5430
|
const textX = _univerjs_core.BuildTextUtils.selection.replaceTextRuns({
|
|
5413
5431
|
doc: docDataModel,
|
|
@@ -6083,10 +6101,10 @@ function insertNamedStyleParagraph(accessor, doc, namedStyleType, startOffset, e
|
|
|
6083
6101
|
segmentId,
|
|
6084
6102
|
unitId: doc.getUnitId()
|
|
6085
6103
|
}));
|
|
6086
|
-
if (success) accessor.get(_univerjs_docs.DocSelectionManagerService).
|
|
6104
|
+
if (success) accessor.get(_univerjs_docs.DocSelectionManagerService).replaceDocRanges([{
|
|
6087
6105
|
startOffset,
|
|
6088
6106
|
endOffset: startOffset
|
|
6089
|
-
}], false);
|
|
6107
|
+
}], void 0, false);
|
|
6090
6108
|
return success;
|
|
6091
6109
|
}
|
|
6092
6110
|
const QuickHeadingCommand = {
|
|
@@ -7202,6 +7220,12 @@ const TEXT_ANCHOR_KEY_PREFIX = "__TestSelectionAnchor__";
|
|
|
7202
7220
|
const ID_LENGTH$1 = 6;
|
|
7203
7221
|
const BLINK_ON = 500;
|
|
7204
7222
|
const TEXT_RANGE_LAYER_INDEX = 3;
|
|
7223
|
+
function cursorConvertToTextRange(scene, range, docSkeleton, document) {
|
|
7224
|
+
const { startOffset, endOffset, style = _univerjs_engine_render.NORMAL_TEXT_SELECTION_PLUGIN_STYLE, segmentId = "", segmentPage } = range;
|
|
7225
|
+
const anchorNodePosition = docSkeleton.findNodePositionByCharIndex(startOffset, true, segmentId, segmentPage);
|
|
7226
|
+
const focusNodePosition = startOffset !== endOffset ? docSkeleton.findNodePositionByCharIndex(endOffset, true, segmentId, segmentPage) : null;
|
|
7227
|
+
return new TextRange(scene, document, docSkeleton, anchorNodePosition, focusNodePosition, style, segmentId, segmentPage);
|
|
7228
|
+
}
|
|
7205
7229
|
function getAnchorBounding(pointsGroup) {
|
|
7206
7230
|
const points = pointsGroup[0];
|
|
7207
7231
|
const startPoint = points[0];
|
|
@@ -7956,7 +7980,7 @@ function getParagraphInfoByGlyph(node) {
|
|
|
7956
7980
|
};
|
|
7957
7981
|
}
|
|
7958
7982
|
function serializeTextRange(textRange) {
|
|
7959
|
-
const { startOffset, endOffset, collapsed, rangeType, startNodePosition, endNodePosition, direction, segmentId, segmentPage } = textRange;
|
|
7983
|
+
const { startOffset, endOffset, collapsed, rangeType, startNodePosition, endNodePosition, direction, segmentId, segmentPage, style } = textRange;
|
|
7960
7984
|
return {
|
|
7961
7985
|
startOffset,
|
|
7962
7986
|
endOffset,
|
|
@@ -7967,6 +7991,7 @@ function serializeTextRange(textRange) {
|
|
|
7967
7991
|
direction,
|
|
7968
7992
|
segmentId,
|
|
7969
7993
|
segmentPage,
|
|
7994
|
+
style,
|
|
7970
7995
|
isActive: textRange.isActive()
|
|
7971
7996
|
};
|
|
7972
7997
|
}
|
|
@@ -8156,27 +8181,37 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8156
8181
|
const { scene, mainComponent } = this._context;
|
|
8157
8182
|
const document = mainComponent;
|
|
8158
8183
|
const docSkeleton = this._docSkeletonManagerService.getSkeleton();
|
|
8159
|
-
const generalAddRange = (startOffset, endOffset) => {
|
|
8160
|
-
const rangeList = getRangeListFromCharIndex(startOffset, endOffset, scene, document, docSkeleton,
|
|
8184
|
+
const generalAddRange = (startOffset, endOffset, rangeStyle) => {
|
|
8185
|
+
const rangeList = getRangeListFromCharIndex(startOffset, endOffset, scene, document, docSkeleton, rangeStyle, segmentId, segmentPage);
|
|
8161
8186
|
if (rangeList == null) return;
|
|
8162
8187
|
const { textRanges, rectRanges } = rangeList;
|
|
8163
8188
|
for (const textRange of textRanges) this._addTextRange(textRange);
|
|
8164
8189
|
this._addRectRanges(rectRanges);
|
|
8165
8190
|
};
|
|
8166
8191
|
for (const range of ranges) {
|
|
8192
|
+
var _range$style;
|
|
8167
8193
|
const { startOffset, endOffset, rangeType, startNodePosition, endNodePosition } = range;
|
|
8168
|
-
|
|
8169
|
-
|
|
8194
|
+
const rangeStyle = (_range$style = range.style) !== null && _range$style !== void 0 ? _range$style : style;
|
|
8195
|
+
if (rangeType !== _univerjs_core.DOC_RANGE_TYPE.RECT && startOffset === endOffset) {
|
|
8196
|
+
const textRange = cursorConvertToTextRange(scene, {
|
|
8197
|
+
...range,
|
|
8198
|
+
segmentId,
|
|
8199
|
+
segmentPage,
|
|
8200
|
+
style: rangeStyle
|
|
8201
|
+
}, docSkeleton, document);
|
|
8202
|
+
if (textRange) this._addTextRange(textRange);
|
|
8203
|
+
} else if (rangeType === _univerjs_core.DOC_RANGE_TYPE.RECT) {
|
|
8204
|
+
const rectRange = getRectRangeFromCharIndex(startOffset, endOffset, scene, document, docSkeleton, rangeStyle, segmentId, segmentPage);
|
|
8170
8205
|
if (rectRange) this._addRectRanges([rectRange]);
|
|
8171
8206
|
} else if (rangeType === _univerjs_core.DOC_RANGE_TYPE.TEXT) try {
|
|
8172
8207
|
let textRange = null;
|
|
8173
|
-
if (startNodePosition && endNodePosition) textRange = getTextRangeFromCharIndex(startNodePosition.isBack ? startOffset : startOffset - 1, endNodePosition.isBack ? endOffset : endOffset - 1, scene, document, docSkeleton,
|
|
8174
|
-
else textRange = getTextRangeFromCharIndex(startOffset, endOffset, scene, document, docSkeleton,
|
|
8208
|
+
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);
|
|
8209
|
+
else textRange = getTextRangeFromCharIndex(startOffset, endOffset, scene, document, docSkeleton, rangeStyle, segmentId, segmentPage);
|
|
8175
8210
|
if (textRange) this._addTextRange(textRange);
|
|
8176
8211
|
} catch (_e) {
|
|
8177
|
-
generalAddRange(startOffset, endOffset);
|
|
8212
|
+
generalAddRange(startOffset, endOffset, rangeStyle);
|
|
8178
8213
|
}
|
|
8179
|
-
else generalAddRange(startOffset, endOffset);
|
|
8214
|
+
else generalAddRange(startOffset, endOffset, rangeStyle);
|
|
8180
8215
|
}
|
|
8181
8216
|
this._textSelectionInner$.next({
|
|
8182
8217
|
textRanges: this._getAllTextRanges(),
|
|
@@ -8247,9 +8282,6 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8247
8282
|
blur() {
|
|
8248
8283
|
this._input.blur();
|
|
8249
8284
|
}
|
|
8250
|
-
/**
|
|
8251
|
-
* @deprecated
|
|
8252
|
-
*/
|
|
8253
8285
|
deactivate() {
|
|
8254
8286
|
this._container.style.left = "0px";
|
|
8255
8287
|
this._container.style.top = "0px";
|
|
@@ -8706,7 +8738,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8706
8738
|
const scrollStop = viewport.onScrollEnd$.subscribeEvent((param) => {
|
|
8707
8739
|
const viewport = param.viewport;
|
|
8708
8740
|
if (!viewport) return;
|
|
8709
|
-
const bounds = viewport.
|
|
8741
|
+
const bounds = viewport.calcViewportInfo();
|
|
8710
8742
|
const activeRangeInstance = this._getActiveRangeInstance();
|
|
8711
8743
|
const anchor = activeRangeInstance === null || activeRangeInstance === void 0 ? void 0 : activeRangeInstance.getAnchor();
|
|
8712
8744
|
if (!anchor || anchor && !anchor.visible) return;
|
|
@@ -8917,8 +8949,8 @@ const SwitchDocModeCommand = {
|
|
|
8917
8949
|
const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
8918
8950
|
if (docDataModel == null) return false;
|
|
8919
8951
|
const unitId = docDataModel.getUnitId();
|
|
8920
|
-
const skeleton = (_renderManagerService = renderManagerService.
|
|
8921
|
-
const docSelectionRenderService = (_renderManagerService2 = renderManagerService.
|
|
8952
|
+
const skeleton = (_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
8953
|
+
const docSelectionRenderService = (_renderManagerService2 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.with(DocSelectionRenderService);
|
|
8922
8954
|
if (skeleton == null || docSelectionRenderService == null) return false;
|
|
8923
8955
|
const segmentId = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.getSegment();
|
|
8924
8956
|
const segmentPage = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.getSegmentPage();
|
|
@@ -9780,7 +9812,7 @@ var Editor = class extends _univerjs_core.Disposable {
|
|
|
9780
9812
|
return docSelectionRenderService.isFocusing && Boolean(docSelectionRenderService.getActiveTextRange());
|
|
9781
9813
|
}
|
|
9782
9814
|
/**
|
|
9783
|
-
*
|
|
9815
|
+
* Focus the input element directly. This is for internal usage.
|
|
9784
9816
|
*/
|
|
9785
9817
|
focus() {
|
|
9786
9818
|
const curDoc = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
@@ -9789,7 +9821,7 @@ var Editor = class extends _univerjs_core.Disposable {
|
|
|
9789
9821
|
this._param.render.with(DocSelectionRenderService).focus();
|
|
9790
9822
|
}
|
|
9791
9823
|
/**
|
|
9792
|
-
*
|
|
9824
|
+
* Blur the input element directly. This is for internal usage.
|
|
9793
9825
|
*/
|
|
9794
9826
|
blur() {
|
|
9795
9827
|
this._param.render.with(DocSelectionRenderService).blur();
|
|
@@ -9869,21 +9901,17 @@ var Editor = class extends _univerjs_core.Disposable {
|
|
|
9869
9901
|
const docDataModel = this._getDocDataModel();
|
|
9870
9902
|
docDataModel === null || docDataModel === void 0 || docDataModel.dispose();
|
|
9871
9903
|
}
|
|
9872
|
-
/**
|
|
9873
|
-
* @deprecated use getEditorId.
|
|
9874
|
-
*/
|
|
9875
|
-
get editorUnitId() {
|
|
9876
|
-
return this._param.editorUnitId;
|
|
9877
|
-
}
|
|
9878
|
-
/**
|
|
9879
|
-
* @deprecated @TODO: @JOCS remove this in the future.
|
|
9880
|
-
*/
|
|
9881
|
-
get params() {
|
|
9882
|
-
return this._param;
|
|
9883
|
-
}
|
|
9884
9904
|
get cancelDefaultResizeListener() {
|
|
9885
9905
|
return this._param.cancelDefaultResizeListener;
|
|
9886
9906
|
}
|
|
9907
|
+
getRenderConfig() {
|
|
9908
|
+
var _this$_param$canvasSt;
|
|
9909
|
+
return {
|
|
9910
|
+
canvasStyle: (_this$_param$canvasSt = this._param.canvasStyle) !== null && _this$_param$canvasSt !== void 0 ? _this$_param$canvasSt : {},
|
|
9911
|
+
scrollBar: this._param.scrollBar,
|
|
9912
|
+
...this._param.backScrollOffset === void 0 ? {} : { backScrollOffset: this._param.backScrollOffset }
|
|
9913
|
+
};
|
|
9914
|
+
}
|
|
9887
9915
|
get render() {
|
|
9888
9916
|
return this._param.render;
|
|
9889
9917
|
}
|
|
@@ -9901,47 +9929,11 @@ var Editor = class extends _univerjs_core.Disposable {
|
|
|
9901
9929
|
}
|
|
9902
9930
|
getSkeleton() {
|
|
9903
9931
|
var _this$_injector$get$g;
|
|
9904
|
-
return (_this$_injector$get$g = this._injector.get(_univerjs_engine_render.IRenderManagerService).
|
|
9932
|
+
return (_this$_injector$get$g = this._injector.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(this._getEditorId())) === null || _this$_injector$get$g === void 0 ? void 0 : _this$_injector$get$g.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
9905
9933
|
}
|
|
9906
9934
|
isSheetEditor() {
|
|
9907
9935
|
return (0, _univerjs_core.isInternalEditorID)(this._getEditorId());
|
|
9908
9936
|
}
|
|
9909
|
-
/**
|
|
9910
|
-
* @deprecated use getDocumentData.
|
|
9911
|
-
*/
|
|
9912
|
-
getValue() {
|
|
9913
|
-
var _docDataModel$getBody;
|
|
9914
|
-
return (((_docDataModel$getBody = this._getDocDataModel().getBody()) === null || _docDataModel$getBody === void 0 ? void 0 : _docDataModel$getBody.dataStream) || "").replace(/\r\n/g, "").replace(/\n/g, "").replace(/\n/g, "");
|
|
9915
|
-
}
|
|
9916
|
-
/**
|
|
9917
|
-
* @deprecated use getDocumentData.
|
|
9918
|
-
*/
|
|
9919
|
-
getBody() {
|
|
9920
|
-
return this._getDocDataModel().getBody();
|
|
9921
|
-
}
|
|
9922
|
-
/**
|
|
9923
|
-
* @deprecated.
|
|
9924
|
-
*/
|
|
9925
|
-
update(param) {
|
|
9926
|
-
this._param = {
|
|
9927
|
-
...this._param,
|
|
9928
|
-
...param
|
|
9929
|
-
};
|
|
9930
|
-
}
|
|
9931
|
-
/**
|
|
9932
|
-
* @deprecated.
|
|
9933
|
-
*/
|
|
9934
|
-
updateCanvasStyle() {
|
|
9935
|
-
var _this$_param$canvasSt;
|
|
9936
|
-
const docDataModel = this._getDocDataModel();
|
|
9937
|
-
if (docDataModel == null) return;
|
|
9938
|
-
const documentStyle = {};
|
|
9939
|
-
if ((_this$_param$canvasSt = this._param.canvasStyle) === null || _this$_param$canvasSt === void 0 ? void 0 : _this$_param$canvasSt.fontSize) {
|
|
9940
|
-
if (documentStyle.textStyle == null) documentStyle.textStyle = {};
|
|
9941
|
-
documentStyle.textStyle.fs = this._param.canvasStyle.fontSize;
|
|
9942
|
-
}
|
|
9943
|
-
docDataModel.updateDocumentStyle(documentStyle);
|
|
9944
|
-
}
|
|
9945
9937
|
_getDocDataModel() {
|
|
9946
9938
|
const editorUnitId = this._getEditorId();
|
|
9947
9939
|
return this._univerInstanceService.getUnit(editorUnitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
@@ -10015,13 +10007,14 @@ let EditorService = class EditorService extends _univerjs_core.Disposable {
|
|
|
10015
10007
|
this._blur$.next(null);
|
|
10016
10008
|
}
|
|
10017
10009
|
focus(editorUnitId) {
|
|
10010
|
+
var _editor$getDocumentDa, _editor$getDocumentDa2;
|
|
10018
10011
|
if (editorUnitId === this._focusEditorUnitId) return;
|
|
10019
10012
|
if (this._focusEditorUnitId) this.blur();
|
|
10020
10013
|
if (editorUnitId == null) return;
|
|
10021
10014
|
const editor = this.getEditor(editorUnitId);
|
|
10022
10015
|
if (editor == null) return;
|
|
10023
10016
|
this._univerInstanceService.setCurrentUnitForType(editorUnitId);
|
|
10024
|
-
const valueCount = editor.
|
|
10017
|
+
const valueCount = ((_editor$getDocumentDa = (_editor$getDocumentDa2 = editor.getDocumentData().body) === null || _editor$getDocumentDa2 === void 0 ? void 0 : _editor$getDocumentDa2.dataStream) !== null && _editor$getDocumentDa !== void 0 ? _editor$getDocumentDa : "").replace(/\r?\n/g, "").length;
|
|
10025
10018
|
this._contextService.setContextValue(_univerjs_core.EDITOR_ACTIVATED, true);
|
|
10026
10019
|
if (!(0, _univerjs_core.isInternalEditorID)(editorUnitId)) this._contextService.setContextValue(_univerjs_core.FOCUSING_EDITOR_STANDALONE, true);
|
|
10027
10020
|
if ((0, _univerjs_core.isCommentEditorID)(editorUnitId)) this._contextService.setContextValue(_univerjs_core.FOCUSING_COMMENT_EDITOR, true);
|
|
@@ -10044,32 +10037,23 @@ let EditorService = class EditorService extends _univerjs_core.Disposable {
|
|
|
10044
10037
|
return this._editors;
|
|
10045
10038
|
}
|
|
10046
10039
|
getEditorRenderConfig(editorUnitId) {
|
|
10047
|
-
var _this$_editorRenderCo;
|
|
10040
|
+
var _ref, _this$_editorRenderCo;
|
|
10048
10041
|
const editor = this._editors.get(editorUnitId);
|
|
10049
|
-
|
|
10050
|
-
var _editor$params$canvas;
|
|
10051
|
-
return {
|
|
10052
|
-
canvasStyle: (_editor$params$canvas = editor.params.canvasStyle) !== null && _editor$params$canvas !== void 0 ? _editor$params$canvas : {},
|
|
10053
|
-
scrollBar: editor.params.scrollBar
|
|
10054
|
-
};
|
|
10055
|
-
}
|
|
10056
|
-
return (_this$_editorRenderCo = this._editorRenderConfigs.get(editorUnitId)) !== null && _this$_editorRenderCo !== void 0 ? _this$_editorRenderCo : null;
|
|
10042
|
+
return (_ref = (_this$_editorRenderCo = this._editorRenderConfigs.get(editorUnitId)) !== null && _this$_editorRenderCo !== void 0 ? _this$_editorRenderCo : editor === null || editor === void 0 ? void 0 : editor.getRenderConfig()) !== null && _ref !== void 0 ? _ref : null;
|
|
10057
10043
|
}
|
|
10058
10044
|
register(config, container) {
|
|
10059
10045
|
const { initialSnapshot, canvasStyle = {} } = config;
|
|
10060
10046
|
const editorUnitId = initialSnapshot.id;
|
|
10061
10047
|
this._editorRenderConfigs.set(editorUnitId, {
|
|
10062
10048
|
canvasStyle,
|
|
10063
|
-
scrollBar: config.scrollBar
|
|
10049
|
+
scrollBar: config.scrollBar,
|
|
10050
|
+
...config.backScrollOffset === void 0 ? {} : { backScrollOffset: config.backScrollOffset }
|
|
10064
10051
|
});
|
|
10065
10052
|
if (this._univerInstanceService.getUnit(editorUnitId, _univerjs_core.UniverInstanceType.UNIVER_DOC) == null) this._univerInstanceService.createUnit(_univerjs_core.UniverInstanceType.UNIVER_DOC, initialSnapshot || this._getBlank(editorUnitId), { makeCurrent: false });
|
|
10066
|
-
let render = this._renderManagerService.
|
|
10067
|
-
if (render == null)
|
|
10068
|
-
this._renderManagerService.create(editorUnitId);
|
|
10069
|
-
render = this._renderManagerService.getRenderById(editorUnitId);
|
|
10070
|
-
}
|
|
10053
|
+
let render = this._renderManagerService.getRenderUnitById(editorUnitId);
|
|
10054
|
+
if (render == null) render = this._renderManagerService.createRender(editorUnitId);
|
|
10071
10055
|
if (render) {
|
|
10072
|
-
render.engine.
|
|
10056
|
+
render.engine.mount(container);
|
|
10073
10057
|
const editor = new Editor({
|
|
10074
10058
|
...config,
|
|
10075
10059
|
render,
|
|
@@ -10179,7 +10163,7 @@ let DocBackScrollRenderController = class DocBackScrollRenderController extends
|
|
|
10179
10163
|
anchorNodePosition && this.scrollToNode(anchorNodePosition);
|
|
10180
10164
|
}
|
|
10181
10165
|
scrollToNode(startNodePosition) {
|
|
10182
|
-
var
|
|
10166
|
+
var _editorRenderConfig$b;
|
|
10183
10167
|
const { unitId, scene, mainComponent } = this._context;
|
|
10184
10168
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
10185
10169
|
if (mainComponent == null || skeleton == null) return;
|
|
@@ -10190,12 +10174,12 @@ let DocBackScrollRenderController = class DocBackScrollRenderController extends
|
|
|
10190
10174
|
const left = aLeft + docsLeft;
|
|
10191
10175
|
const top = aTop + docsTop;
|
|
10192
10176
|
const viewportMain = scene.getViewport("viewMain");
|
|
10193
|
-
const editor = this._editorService.getEditor(unitId);
|
|
10194
10177
|
if (viewportMain == null) return;
|
|
10195
|
-
const { left: boundLeft, top: boundTop, right: boundRight, bottom: boundBottom } = viewportMain.
|
|
10178
|
+
const { left: boundLeft, top: boundTop, right: boundRight, bottom: boundBottom } = viewportMain.calcViewportInfo().viewBound;
|
|
10196
10179
|
let offsetY = 0;
|
|
10197
10180
|
let offsetX = 0;
|
|
10198
|
-
const
|
|
10181
|
+
const editorRenderConfig = this._editorService.getEditorRenderConfig(unitId);
|
|
10182
|
+
const delta = editorRenderConfig ? (_editorRenderConfig$b = editorRenderConfig.backScrollOffset) !== null && _editorRenderConfig$b !== void 0 ? _editorRenderConfig$b : 0 : 100;
|
|
10199
10183
|
if (top < boundTop) offsetY = top - boundTop - delta;
|
|
10200
10184
|
else if (top > boundBottom - height) offsetY = top - boundBottom + height + delta;
|
|
10201
10185
|
if (left < boundLeft) offsetX = left - boundLeft;
|
|
@@ -10241,12 +10225,15 @@ let DocParagraphPlaceholderRenderController = class DocParagraphPlaceholderRende
|
|
|
10241
10225
|
this.disposeWithMe(documents.pageRender$.subscribe((pageRenderConfig) => this._drawPagePlaceholders(pageRenderConfig)));
|
|
10242
10226
|
}
|
|
10243
10227
|
_drawPagePlaceholders({ page, pageLeft, pageTop, ctx }) {
|
|
10244
|
-
var _this$_context$unit$g, _activeRange$segmentI, _page$segmentId;
|
|
10228
|
+
var _this$_context$unit$g, _activeRange$segmentI, _page$segmentId, _this$_context$mainCo;
|
|
10245
10229
|
const body = (_this$_context$unit$g = this._context.unit.getSelfOrHeaderFooterModel(page.segmentId)) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.getBody();
|
|
10246
10230
|
if (!body) return;
|
|
10247
10231
|
const activeRange = this._docSelectionManagerService.getActiveTextRange();
|
|
10248
10232
|
if (!activeRange || ((_activeRange$segmentI = activeRange.segmentId) !== null && _activeRange$segmentI !== void 0 ? _activeRange$segmentI : "") !== ((_page$segmentId = page.segmentId) !== null && _page$segmentId !== void 0 ? _page$segmentId : "")) return;
|
|
10249
|
-
const placeholders = getParagraphPlaceholderLayouts(page, body, this._getLocale(), pageLeft, pageTop, activeRange.startOffset
|
|
10233
|
+
const placeholders = getParagraphPlaceholderLayouts(page, body, this._getLocale(), pageLeft, pageTop, activeRange.startOffset, {
|
|
10234
|
+
docsLeft: (_this$_context$mainCo = this._context.mainComponent) === null || _this$_context$mainCo === void 0 ? void 0 : _this$_context$mainCo.getOffsetConfig().docsLeft,
|
|
10235
|
+
unitId: this._context.unitId
|
|
10236
|
+
});
|
|
10250
10237
|
if (!placeholders.length) return;
|
|
10251
10238
|
drawParagraphPlaceholders(ctx, placeholders);
|
|
10252
10239
|
}
|
|
@@ -10273,20 +10260,39 @@ function shouldRenderParagraphPlaceholder(documentModel, unitId, config) {
|
|
|
10273
10260
|
if ((0, _univerjs_core.isInternalEditorID)(unitId)) return false;
|
|
10274
10261
|
return ((_documentModel$getSna = documentModel.getSnapshot().documentStyle) === null || _documentModel$getSna === void 0 ? void 0 : _documentModel$getSna.documentFlavor) === _univerjs_core.DocumentFlavor.MODERN;
|
|
10275
10262
|
}
|
|
10276
|
-
function getParagraphPlaceholderLayouts(page, body, locale, pageLeft = 0, pageTop = 0, activeOffset) {
|
|
10263
|
+
function getParagraphPlaceholderLayouts(page, body, locale, pageLeft = 0, pageTop = 0, activeOffset, options) {
|
|
10277
10264
|
var _body$paragraphs, _page$skeTables;
|
|
10278
10265
|
const paragraphs = new Map(((_body$paragraphs = body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).map((paragraph) => [paragraph.startIndex, paragraph]));
|
|
10279
10266
|
const layouts = [];
|
|
10280
|
-
const visitSection = (section, originLeft, originTop) => {
|
|
10281
|
-
for (const column of section.columns) visitColumn(column, body, paragraphs, locale, layouts, originLeft + column.left, originTop + section.top, activeOffset);
|
|
10267
|
+
const visitSection = (section, originLeft, originTop, clip) => {
|
|
10268
|
+
for (const column of section.columns) visitColumn(column, body, paragraphs, locale, layouts, originLeft + column.left, originTop + section.top, activeOffset, clip);
|
|
10282
10269
|
};
|
|
10283
10270
|
for (const section of page.sections) visitSection(section, pageLeft + page.marginLeft, pageTop + page.marginTop);
|
|
10284
|
-
(_page$skeTables = page.skeTables) === null || _page$skeTables === void 0 || _page$skeTables.forEach((table) => {
|
|
10285
|
-
|
|
10271
|
+
(_page$skeTables = page.skeTables) === null || _page$skeTables === void 0 || _page$skeTables.forEach((table, tableId) => {
|
|
10272
|
+
var _table$tableId, _options$unitId, _viewport$leadingInse, _viewport$trailingIns, _viewport$leadingInse2;
|
|
10273
|
+
const sourceTableId = (0, _univerjs_engine_render.getTableIdAndSliceIndex)((_table$tableId = table.tableId) !== null && _table$tableId !== void 0 ? _table$tableId : tableId).tableId;
|
|
10274
|
+
const viewport = (0, _univerjs_engine_render.getDocsTableRenderViewport)((_options$unitId = options === null || options === void 0 ? void 0 : options.unitId) !== null && _options$unitId !== void 0 ? _options$unitId : "", sourceTableId);
|
|
10275
|
+
const hasHorizontalViewport = viewport != null && ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0) + viewport.contentWidth + ((_viewport$trailingIns = viewport.trailingInsetRight) !== null && _viewport$trailingIns !== void 0 ? _viewport$trailingIns : 0) > viewport.viewportWidth;
|
|
10276
|
+
const tableLeft = pageLeft + page.marginLeft + table.left;
|
|
10277
|
+
const tableViewportLeft = hasHorizontalViewport ? (0, _univerjs_engine_render.getDocsTableViewportLeft)(viewport, tableLeft - ((_viewport$leadingInse2 = viewport.leadingInsetLeft) !== null && _viewport$leadingInse2 !== void 0 ? _viewport$leadingInse2 : 0), options === null || options === void 0 ? void 0 : options.docsLeft) : tableLeft;
|
|
10278
|
+
const tableViewportRight = tableViewportLeft + (hasHorizontalViewport ? viewport.viewportWidth : table.width);
|
|
10279
|
+
const tableScrollLeft = hasHorizontalViewport ? viewport.scrollLeft : 0;
|
|
10280
|
+
for (const row of table.rows) for (const cell of row.cells) {
|
|
10281
|
+
const cellLeft = tableLeft + cell.left - tableScrollLeft;
|
|
10282
|
+
const cellContentLeft = cellLeft + cell.marginLeft;
|
|
10283
|
+
const cellContentRight = cellLeft + cell.pageWidth - cell.marginRight;
|
|
10284
|
+
const clipLeft = Math.max(cellContentLeft, tableViewportLeft);
|
|
10285
|
+
const clipRight = Math.min(cellContentRight, tableViewportRight);
|
|
10286
|
+
if (clipRight <= clipLeft) continue;
|
|
10287
|
+
for (const section of cell.sections) visitSection(section, cellContentLeft, pageTop + page.marginTop + table.top + row.top + cell.marginTop, {
|
|
10288
|
+
left: clipLeft,
|
|
10289
|
+
right: clipRight
|
|
10290
|
+
});
|
|
10291
|
+
}
|
|
10286
10292
|
});
|
|
10287
10293
|
return layouts;
|
|
10288
10294
|
}
|
|
10289
|
-
function visitColumn(column, body, paragraphs, locale, layouts, originLeft, originTop, activeOffset) {
|
|
10295
|
+
function visitColumn(column, body, paragraphs, locale, layouts, originLeft, originTop, activeOffset, clip) {
|
|
10290
10296
|
for (const line of column.lines) {
|
|
10291
10297
|
if (!line.paragraphStart) continue;
|
|
10292
10298
|
const paragraphStart = line.st;
|
|
@@ -10296,7 +10302,7 @@ function visitColumn(column, body, paragraphs, locale, layouts, originLeft, orig
|
|
|
10296
10302
|
if (!paragraph || !isEmptyParagraph(body.dataStream, line.st, line.paragraphIndex)) continue;
|
|
10297
10303
|
const text = getPlaceholderText(paragraph, locale);
|
|
10298
10304
|
if (!text) continue;
|
|
10299
|
-
layouts.push(getLinePlaceholderLayout(line, paragraph, text, originLeft, originTop));
|
|
10305
|
+
layouts.push(getLinePlaceholderLayout(line, paragraph, text, originLeft, originTop, clip));
|
|
10300
10306
|
}
|
|
10301
10307
|
}
|
|
10302
10308
|
function isOffsetInParagraph(offset, paragraphStart, paragraphEnd) {
|
|
@@ -10314,8 +10320,8 @@ function getPlaceholderText(paragraph, locale) {
|
|
|
10314
10320
|
default: return locale.normalText;
|
|
10315
10321
|
}
|
|
10316
10322
|
}
|
|
10317
|
-
function getLinePlaceholderLayout(line, paragraph, text, originLeft, originTop) {
|
|
10318
|
-
var _divide$glyphGroup, _paragraph$paragraphS2, _paragraph$paragraphS3, _getLineFontFamily, _divide$left, _divide$paddingLeft, _ref, _divide$width;
|
|
10323
|
+
function getLinePlaceholderLayout(line, paragraph, text, originLeft, originTop, clip) {
|
|
10324
|
+
var _divide$glyphGroup, _paragraph$paragraphS2, _paragraph$paragraphS3, _getLineFontFamily, _divide$left, _divide$paddingLeft, _ref, _divide$width, _clip$left, _clip$right;
|
|
10319
10325
|
const divide = line.divides[0];
|
|
10320
10326
|
const firstGlyph = ((_divide$glyphGroup = divide === null || divide === void 0 ? void 0 : divide.glyphGroup) !== null && _divide$glyphGroup !== void 0 ? _divide$glyphGroup : [])[0];
|
|
10321
10327
|
const textStyle = _univerjs_core.NAMED_STYLE_MAP[(_paragraph$paragraphS2 = (_paragraph$paragraphS3 = paragraph.paragraphStyle) === null || _paragraph$paragraphS3 === void 0 ? void 0 : _paragraph$paragraphS3.namedStyleType) !== null && _paragraph$paragraphS2 !== void 0 ? _paragraph$paragraphS2 : _univerjs_core.NamedStyleType.NORMAL_TEXT];
|
|
@@ -10324,13 +10330,22 @@ function getLinePlaceholderLayout(line, paragraph, text, originLeft, originTop)
|
|
|
10324
10330
|
const fontWeight = (textStyle === null || textStyle === void 0 ? void 0 : textStyle.bl) ? "bold" : "normal";
|
|
10325
10331
|
const lineStartX = originLeft + ((_divide$left = divide === null || divide === void 0 ? void 0 : divide.left) !== null && _divide$left !== void 0 ? _divide$left : 0) + ((_divide$paddingLeft = divide === null || divide === void 0 ? void 0 : divide.paddingLeft) !== null && _divide$paddingLeft !== void 0 ? _divide$paddingLeft : 0);
|
|
10326
10332
|
const listOffset = paragraph.bullet && firstGlyph ? firstGlyph.left + firstGlyph.width + LIST_PLACEHOLDER_GAP : 0;
|
|
10333
|
+
const x = lineStartX + listOffset;
|
|
10334
|
+
const naturalMaxWidth = Math.max(0, ((_ref = (_divide$width = divide === null || divide === void 0 ? void 0 : divide.width) !== null && _divide$width !== void 0 ? _divide$width : line.width) !== null && _ref !== void 0 ? _ref : 0) - listOffset);
|
|
10335
|
+
const clipLeft = Math.max(x, (_clip$left = clip === null || clip === void 0 ? void 0 : clip.left) !== null && _clip$left !== void 0 ? _clip$left : x);
|
|
10336
|
+
const clipRight = Math.min(x + naturalMaxWidth, (_clip$right = clip === null || clip === void 0 ? void 0 : clip.right) !== null && _clip$right !== void 0 ? _clip$right : x + naturalMaxWidth);
|
|
10337
|
+
const clipTop = originTop + line.top;
|
|
10327
10338
|
return {
|
|
10339
|
+
clipBottom: clipTop + line.lineHeight,
|
|
10340
|
+
clipLeft,
|
|
10341
|
+
clipRight,
|
|
10342
|
+
clipTop,
|
|
10328
10343
|
fontFamily,
|
|
10329
10344
|
fontSize,
|
|
10330
10345
|
fontWeight,
|
|
10331
|
-
maxWidth: Math.max(0,
|
|
10346
|
+
maxWidth: Math.max(0, clipRight - clipLeft),
|
|
10332
10347
|
text,
|
|
10333
|
-
x
|
|
10348
|
+
x,
|
|
10334
10349
|
y: originTop + line.top + line.marginTop + line.paddingTop + line.asc
|
|
10335
10350
|
};
|
|
10336
10351
|
}
|
|
@@ -10370,8 +10385,20 @@ function drawParagraphPlaceholders(ctx, placeholders) {
|
|
|
10370
10385
|
ctx.fillStyle = PLACEHOLDER_COLOR;
|
|
10371
10386
|
ctx.textBaseline = "alphabetic";
|
|
10372
10387
|
for (const placeholder of placeholders) {
|
|
10388
|
+
var _placeholder$clipLeft, _placeholder$clipRigh, _placeholder$clipTop, _placeholder$clipBott;
|
|
10389
|
+
const clipLeft = (_placeholder$clipLeft = placeholder.clipLeft) !== null && _placeholder$clipLeft !== void 0 ? _placeholder$clipLeft : placeholder.x;
|
|
10390
|
+
const clipRight = (_placeholder$clipRigh = placeholder.clipRight) !== null && _placeholder$clipRigh !== void 0 ? _placeholder$clipRigh : placeholder.x + placeholder.maxWidth;
|
|
10391
|
+
const clipTop = (_placeholder$clipTop = placeholder.clipTop) !== null && _placeholder$clipTop !== void 0 ? _placeholder$clipTop : placeholder.y - placeholder.fontSize;
|
|
10392
|
+
const clipBottom = (_placeholder$clipBott = placeholder.clipBottom) !== null && _placeholder$clipBott !== void 0 ? _placeholder$clipBott : placeholder.y + placeholder.fontSize;
|
|
10393
|
+
if (clipRight <= clipLeft || clipBottom <= clipTop) continue;
|
|
10394
|
+
ctx.save();
|
|
10395
|
+
ctx.beginPath();
|
|
10396
|
+
ctx.rectByPrecision(clipLeft, clipTop, clipRight - clipLeft, clipBottom - clipTop);
|
|
10397
|
+
ctx.closePath();
|
|
10398
|
+
ctx.clip();
|
|
10373
10399
|
ctx.font = `${placeholder.fontWeight} ${placeholder.fontSize}px ${placeholder.fontFamily}`;
|
|
10374
|
-
ctx.fillText(placeholder.text, placeholder.x, placeholder.y
|
|
10400
|
+
ctx.fillText(placeholder.text, placeholder.x, placeholder.y);
|
|
10401
|
+
ctx.restore();
|
|
10375
10402
|
}
|
|
10376
10403
|
ctx.restore();
|
|
10377
10404
|
}
|
|
@@ -10518,7 +10545,10 @@ let DocPageLayoutService = class DocPageLayoutService extends _univerjs_core.Dis
|
|
|
10518
10545
|
}
|
|
10519
10546
|
if (engineHeight > docsHeight) sceneHeight = (engineHeight - pageMarginTop * 2) / viewScale;
|
|
10520
10547
|
else sceneHeight = docsHeight + pageMarginTop * 2;
|
|
10521
|
-
scene.
|
|
10548
|
+
scene.transformByState({
|
|
10549
|
+
width: sceneWidth,
|
|
10550
|
+
height: sceneHeight
|
|
10551
|
+
});
|
|
10522
10552
|
if (engineWidth <= 1) {
|
|
10523
10553
|
docsLeft = -1e4;
|
|
10524
10554
|
docsTop = -1e4;
|
|
@@ -10555,7 +10585,7 @@ let DocRenderController = class DocRenderController extends _univerjs_core.RxDis
|
|
|
10555
10585
|
}
|
|
10556
10586
|
reRender(unitId) {
|
|
10557
10587
|
var _this$_renderManagerS;
|
|
10558
|
-
const docSkeletonManagerService = (_this$_renderManagerS = this._renderManagerService.
|
|
10588
|
+
const docSkeletonManagerService = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_docs.DocSkeletonManagerService);
|
|
10559
10589
|
const skeleton = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getSkeleton();
|
|
10560
10590
|
if (!skeleton) return;
|
|
10561
10591
|
if (!!skeleton.getViewModel().getDataModel().getSnapshot().disabled) return;
|
|
@@ -10703,7 +10733,10 @@ let DocRenderController = class DocRenderController extends _univerjs_core.RxDis
|
|
|
10703
10733
|
docsComponent.resize(width, height);
|
|
10704
10734
|
docBackground.resize(width, height);
|
|
10705
10735
|
const editorRenderConfig = this._editorService.getEditorRenderConfig(unitId);
|
|
10706
|
-
if (!editorRenderConfig || editorRenderConfig.scrollBar) scene.
|
|
10736
|
+
if (!editorRenderConfig || editorRenderConfig.scrollBar) scene.transformByState({
|
|
10737
|
+
width,
|
|
10738
|
+
height
|
|
10739
|
+
});
|
|
10707
10740
|
}
|
|
10708
10741
|
_syncCanvasBackground(documentFlavor = this._context.unit.getSnapshot().documentStyle.documentFlavor) {
|
|
10709
10742
|
var _docBackground$setFil;
|
|
@@ -10891,7 +10924,7 @@ const CloseHeaderFooterCommand = {
|
|
|
10891
10924
|
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
10892
10925
|
const unitId = (_params$unitId = params === null || params === void 0 ? void 0 : params.unitId) !== null && _params$unitId !== void 0 ? _params$unitId : (_instanceService$getC = instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _instanceService$getC === void 0 ? void 0 : _instanceService$getC.getUnitId();
|
|
10893
10926
|
if (unitId == null) return false;
|
|
10894
|
-
const renderObject = renderManagerService.
|
|
10927
|
+
const renderObject = renderManagerService.getRenderUnitById(unitId);
|
|
10895
10928
|
if (renderObject == null) return false;
|
|
10896
10929
|
const docSkeletonManagerService = renderObject.with(_univerjs_docs.DocSkeletonManagerService);
|
|
10897
10930
|
const viewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
@@ -11012,9 +11045,10 @@ const DOC_SECTION_SETTING_COMPONENT = "doc_ui_section-setting-panel";
|
|
|
11012
11045
|
* limitations under the License.
|
|
11013
11046
|
*/
|
|
11014
11047
|
let DocSectionSettingController = class DocSectionSettingController extends _univerjs_core.Disposable {
|
|
11015
|
-
constructor(_sidebarService) {
|
|
11048
|
+
constructor(_sidebarService, _selectionManager) {
|
|
11016
11049
|
super();
|
|
11017
11050
|
this._sidebarService = _sidebarService;
|
|
11051
|
+
this._selectionManager = _selectionManager;
|
|
11018
11052
|
_defineProperty(this, "_panelId", "DocSectionSetting");
|
|
11019
11053
|
}
|
|
11020
11054
|
openPanel() {
|
|
@@ -11028,8 +11062,19 @@ let DocSectionSettingController = class DocSectionSettingController extends _uni
|
|
|
11028
11062
|
closePanel() {
|
|
11029
11063
|
this._sidebarService.close(this._panelId);
|
|
11030
11064
|
}
|
|
11065
|
+
navigateToSectionEnd(unitId, sectionStart, sectionEnd) {
|
|
11066
|
+
const params = {
|
|
11067
|
+
unitId,
|
|
11068
|
+
subUnitId: unitId
|
|
11069
|
+
};
|
|
11070
|
+
const cursorOffset = Math.max(sectionStart, sectionEnd - 1);
|
|
11071
|
+
this._selectionManager.replaceDocRanges([{
|
|
11072
|
+
startOffset: cursorOffset,
|
|
11073
|
+
endOffset: cursorOffset
|
|
11074
|
+
}], params, true, { shouldFocus: false });
|
|
11075
|
+
}
|
|
11031
11076
|
};
|
|
11032
|
-
DocSectionSettingController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService))], DocSectionSettingController);
|
|
11077
|
+
DocSectionSettingController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService))], DocSectionSettingController);
|
|
11033
11078
|
|
|
11034
11079
|
//#endregion
|
|
11035
11080
|
//#region src/commands/operations/doc-section-setting-panel.operation.ts
|
|
@@ -11042,6 +11087,52 @@ const DocSectionSettingPanelOperation = {
|
|
|
11042
11087
|
}
|
|
11043
11088
|
};
|
|
11044
11089
|
|
|
11090
|
+
//#endregion
|
|
11091
|
+
//#region src/commands/operations/insert-break.operation.ts
|
|
11092
|
+
function getCollapsedBodyOffset(selectionManager) {
|
|
11093
|
+
const range = selectionManager.getActiveTextRange();
|
|
11094
|
+
if (!(range === null || range === void 0 ? void 0 : range.collapsed) || range.segmentId || !Number.isInteger(range.startOffset)) return null;
|
|
11095
|
+
return range.startOffset;
|
|
11096
|
+
}
|
|
11097
|
+
const InsertDocumentColumnBreakOperation = {
|
|
11098
|
+
id: "docs.operation.insert-column-break",
|
|
11099
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
11100
|
+
handler: (accessor) => {
|
|
11101
|
+
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
11102
|
+
const selectionManager = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
11103
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
11104
|
+
const document = instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
11105
|
+
const offset = getCollapsedBodyOffset(selectionManager);
|
|
11106
|
+
if (!document || document.getDocumentStyle().documentFlavor !== _univerjs_core.DocumentFlavor.TRADITIONAL || offset == null) return false;
|
|
11107
|
+
return commandService.syncExecuteCommand(_univerjs_docs.InsertDocumentColumnBreakCommand.id, {
|
|
11108
|
+
unitId: document.getUnitId(),
|
|
11109
|
+
offset
|
|
11110
|
+
});
|
|
11111
|
+
}
|
|
11112
|
+
};
|
|
11113
|
+
const InsertDocumentSectionBreakOperation = {
|
|
11114
|
+
id: "docs.operation.insert-section-break",
|
|
11115
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
11116
|
+
handler: (accessor, params) => {
|
|
11117
|
+
var _body$sectionBreaks;
|
|
11118
|
+
if (!params) return false;
|
|
11119
|
+
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
11120
|
+
const selectionManager = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
11121
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
11122
|
+
const document = instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
11123
|
+
const offset = getCollapsedBodyOffset(selectionManager);
|
|
11124
|
+
const body = document === null || document === void 0 ? void 0 : document.getBody();
|
|
11125
|
+
if (!document || !body || document.getDocumentStyle().documentFlavor !== _univerjs_core.DocumentFlavor.TRADITIONAL || offset == null) return false;
|
|
11126
|
+
const sectionId = (0, _univerjs_core.createSectionId)(new Set((_body$sectionBreaks = body.sectionBreaks) === null || _body$sectionBreaks === void 0 ? void 0 : _body$sectionBreaks.map((section) => section.sectionId)));
|
|
11127
|
+
return commandService.syncExecuteCommand(_univerjs_docs.InsertDocumentSectionBreakCommand.id, {
|
|
11128
|
+
unitId: document.getUnitId(),
|
|
11129
|
+
offset,
|
|
11130
|
+
sectionId,
|
|
11131
|
+
nextSectionType: params.sectionType
|
|
11132
|
+
});
|
|
11133
|
+
}
|
|
11134
|
+
};
|
|
11135
|
+
|
|
11045
11136
|
//#endregion
|
|
11046
11137
|
//#region src/views/PageSettings.tsx
|
|
11047
11138
|
const MODERN_WIDTH_OPTIONS = [
|
|
@@ -11712,6 +11803,7 @@ const ListTypePicker = (props) => {
|
|
|
11712
11803
|
const { value, onChange, options } = props;
|
|
11713
11804
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11714
11805
|
className: "univer-grid univer-grid-cols-3 univer-gap-2 univer-p-1.5",
|
|
11806
|
+
"data-u-editor-interaction-boundary": "true",
|
|
11715
11807
|
children: options.map((item) => {
|
|
11716
11808
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
11717
11809
|
className: (0, _univerjs_design.clsx)("univer-block univer-h-20 univer-w-[72px] univer-cursor-pointer univer-overflow-hidden univer-rounded univer-transition-all hover:univer-border-primary-500", _univerjs_design.borderClassName, { "univer-border-primary-500": value === item.value }),
|
|
@@ -11842,7 +11934,7 @@ function getInsertTableHiddenObservable(accessor) {
|
|
|
11842
11934
|
editAreaSubscription = null;
|
|
11843
11935
|
if (unitId == null) return subscriber.next(true);
|
|
11844
11936
|
if (univerInstanceService.getUnitType(unitId) !== _univerjs_core.UniverInstanceType.UNIVER_DOC) return subscriber.next(true);
|
|
11845
|
-
const currentRender = renderManagerService.
|
|
11937
|
+
const currentRender = renderManagerService.getRenderUnitById(unitId);
|
|
11846
11938
|
if (currentRender == null) return subscriber.next(true);
|
|
11847
11939
|
editAreaSubscription = currentRender.with(_univerjs_docs.DocSkeletonManagerService).getViewModel().editAreaChange$.subscribe((editArea) => {
|
|
11848
11940
|
subscriber.next(editArea === _univerjs_engine_render.DocumentEditArea.HEADER || editArea === _univerjs_engine_render.DocumentEditArea.FOOTER);
|
|
@@ -11873,7 +11965,7 @@ function disableMenuWhenHeaderFooterEditing(accessor) {
|
|
|
11873
11965
|
emit(true);
|
|
11874
11966
|
return;
|
|
11875
11967
|
}
|
|
11876
|
-
const currentRender = renderManagerService.
|
|
11968
|
+
const currentRender = renderManagerService.getRenderUnitById(unitId);
|
|
11877
11969
|
const skeletonManager = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(_univerjs_docs.DocSkeletonManagerService);
|
|
11878
11970
|
const viewModel = skeletonManager === null || skeletonManager === void 0 ? void 0 : skeletonManager.getViewModel();
|
|
11879
11971
|
if (!viewModel) {
|
|
@@ -11894,7 +11986,7 @@ function disableMenuWhenHeaderFooterEditing(accessor) {
|
|
|
11894
11986
|
};
|
|
11895
11987
|
});
|
|
11896
11988
|
}
|
|
11897
|
-
function
|
|
11989
|
+
function getTraditionalDocMenuHiddenObservable(accessor) {
|
|
11898
11990
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
11899
11991
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
11900
11992
|
return new rxjs.Observable((subscriber) => {
|
|
@@ -12502,11 +12594,60 @@ function HeaderFooterMenuItemFactory(accessor) {
|
|
|
12502
12594
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
12503
12595
|
icon: "HeaderFooterIcon",
|
|
12504
12596
|
tooltip: "docs-ui.toolbar.headerFooter",
|
|
12505
|
-
hidden$: (0, rxjs.combineLatest)((0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC),
|
|
12597
|
+
hidden$: (0, rxjs.combineLatest)((0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC), getTraditionalDocMenuHiddenObservable(accessor), (one, two) => {
|
|
12506
12598
|
return one || two;
|
|
12507
12599
|
})
|
|
12508
12600
|
};
|
|
12509
12601
|
}
|
|
12602
|
+
const DOC_BREAKS_MENU_ID = "doc.menu.breaks";
|
|
12603
|
+
const DOC_SECTION_BREAK_NEXT_PAGE_MENU_ID = "doc.menu.section-break.next-page";
|
|
12604
|
+
const DOC_SECTION_BREAK_CONTINUOUS_MENU_ID = "doc.menu.section-break.continuous";
|
|
12605
|
+
const DOC_SECTION_BREAK_NEXT_COLUMN_MENU_ID = "doc.menu.section-break.next-column";
|
|
12606
|
+
const DOC_SECTION_BREAK_EVEN_PAGE_MENU_ID = "doc.menu.section-break.even-page";
|
|
12607
|
+
const DOC_SECTION_BREAK_ODD_PAGE_MENU_ID = "doc.menu.section-break.odd-page";
|
|
12608
|
+
function BreaksMenuFactory(accessor) {
|
|
12609
|
+
return {
|
|
12610
|
+
id: DOC_BREAKS_MENU_ID,
|
|
12611
|
+
type: _univerjs_ui.MenuItemType.SUBITEMS,
|
|
12612
|
+
icon: "ColumnIcon",
|
|
12613
|
+
tooltip: "docs-ui.toolbar.breaks",
|
|
12614
|
+
disabled$: disableMenuWhenNoDocRange(accessor),
|
|
12615
|
+
hidden$: (0, rxjs.combineLatest)((0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC), getTraditionalDocMenuHiddenObservable(accessor), (hidden, unsupported) => hidden || unsupported)
|
|
12616
|
+
};
|
|
12617
|
+
}
|
|
12618
|
+
function InsertColumnBreakMenuFactory(accessor) {
|
|
12619
|
+
return {
|
|
12620
|
+
id: InsertDocumentColumnBreakOperation.id,
|
|
12621
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
12622
|
+
title: "docs-ui.toolbar.columnBreak",
|
|
12623
|
+
disabled$: disableMenuWhenNoDocRange(accessor)
|
|
12624
|
+
};
|
|
12625
|
+
}
|
|
12626
|
+
function createSectionBreakMenuItem(accessor, id, title, sectionType) {
|
|
12627
|
+
return {
|
|
12628
|
+
id,
|
|
12629
|
+
commandId: InsertDocumentSectionBreakOperation.id,
|
|
12630
|
+
params: { sectionType },
|
|
12631
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
12632
|
+
title,
|
|
12633
|
+
disabled$: disableMenuWhenNoDocRange(accessor)
|
|
12634
|
+
};
|
|
12635
|
+
}
|
|
12636
|
+
function InsertNextPageSectionBreakMenuFactory(accessor) {
|
|
12637
|
+
return createSectionBreakMenuItem(accessor, DOC_SECTION_BREAK_NEXT_PAGE_MENU_ID, "docs-ui.toolbar.sectionBreakNextPage", _univerjs_core.SectionType.NEXT_PAGE);
|
|
12638
|
+
}
|
|
12639
|
+
function InsertContinuousSectionBreakMenuFactory(accessor) {
|
|
12640
|
+
return createSectionBreakMenuItem(accessor, DOC_SECTION_BREAK_CONTINUOUS_MENU_ID, "docs-ui.toolbar.sectionBreakContinuous", _univerjs_core.SectionType.CONTINUOUS);
|
|
12641
|
+
}
|
|
12642
|
+
function InsertNextColumnSectionBreakMenuFactory(accessor) {
|
|
12643
|
+
return createSectionBreakMenuItem(accessor, DOC_SECTION_BREAK_NEXT_COLUMN_MENU_ID, "docs-ui.toolbar.sectionBreakNextColumn", _univerjs_core.SectionType.NEXT_COLUMN);
|
|
12644
|
+
}
|
|
12645
|
+
function InsertEvenPageSectionBreakMenuFactory(accessor) {
|
|
12646
|
+
return createSectionBreakMenuItem(accessor, DOC_SECTION_BREAK_EVEN_PAGE_MENU_ID, "docs-ui.toolbar.sectionBreakEvenPage", _univerjs_core.SectionType.EVEN_PAGE);
|
|
12647
|
+
}
|
|
12648
|
+
function InsertOddPageSectionBreakMenuFactory(accessor) {
|
|
12649
|
+
return createSectionBreakMenuItem(accessor, DOC_SECTION_BREAK_ODD_PAGE_MENU_ID, "docs-ui.toolbar.sectionBreakOddPage", _univerjs_core.SectionType.ODD_PAGE);
|
|
12650
|
+
}
|
|
12510
12651
|
const TableIcon = "GridIcon";
|
|
12511
12652
|
const TABLE_MENU_ID = "doc.menu.table";
|
|
12512
12653
|
function TableMenuFactory(accessor) {
|
|
@@ -13719,19 +13860,53 @@ const menuSchema = {
|
|
|
13719
13860
|
},
|
|
13720
13861
|
menuItemFactory: HorizontalLineFactory
|
|
13721
13862
|
},
|
|
13722
|
-
[
|
|
13863
|
+
[DOC_BREAKS_MENU_ID]: {
|
|
13723
13864
|
order: 4,
|
|
13724
13865
|
gridLayout: {
|
|
13725
13866
|
row: 1,
|
|
13726
|
-
column: 3
|
|
13867
|
+
column: 3,
|
|
13868
|
+
rowSpan: 2,
|
|
13869
|
+
showLabel: true
|
|
13870
|
+
},
|
|
13871
|
+
menuItemFactory: BreaksMenuFactory,
|
|
13872
|
+
[InsertDocumentColumnBreakOperation.id]: {
|
|
13873
|
+
order: 0,
|
|
13874
|
+
menuItemFactory: InsertColumnBreakMenuFactory
|
|
13875
|
+
},
|
|
13876
|
+
[DOC_SECTION_BREAK_NEXT_PAGE_MENU_ID]: {
|
|
13877
|
+
order: 1,
|
|
13878
|
+
menuItemFactory: InsertNextPageSectionBreakMenuFactory
|
|
13879
|
+
},
|
|
13880
|
+
[DOC_SECTION_BREAK_CONTINUOUS_MENU_ID]: {
|
|
13881
|
+
order: 2,
|
|
13882
|
+
menuItemFactory: InsertContinuousSectionBreakMenuFactory
|
|
13883
|
+
},
|
|
13884
|
+
[DOC_SECTION_BREAK_NEXT_COLUMN_MENU_ID]: {
|
|
13885
|
+
order: 3,
|
|
13886
|
+
menuItemFactory: InsertNextColumnSectionBreakMenuFactory
|
|
13887
|
+
},
|
|
13888
|
+
[DOC_SECTION_BREAK_EVEN_PAGE_MENU_ID]: {
|
|
13889
|
+
order: 4,
|
|
13890
|
+
menuItemFactory: InsertEvenPageSectionBreakMenuFactory
|
|
13891
|
+
},
|
|
13892
|
+
[DOC_SECTION_BREAK_ODD_PAGE_MENU_ID]: {
|
|
13893
|
+
order: 5,
|
|
13894
|
+
menuItemFactory: InsertOddPageSectionBreakMenuFactory
|
|
13895
|
+
}
|
|
13896
|
+
},
|
|
13897
|
+
[DOC_INSERT_EMOJI_MENU_ID]: {
|
|
13898
|
+
order: 5,
|
|
13899
|
+
gridLayout: {
|
|
13900
|
+
row: 1,
|
|
13901
|
+
column: 4
|
|
13727
13902
|
},
|
|
13728
13903
|
menuItemFactory: EmojiPickerMenuItemFactory
|
|
13729
13904
|
},
|
|
13730
13905
|
[DOC_INSERT_SYMBOL_MENU_ID]: {
|
|
13731
|
-
order:
|
|
13906
|
+
order: 6,
|
|
13732
13907
|
gridLayout: {
|
|
13733
13908
|
row: 2,
|
|
13734
|
-
column:
|
|
13909
|
+
column: 4
|
|
13735
13910
|
},
|
|
13736
13911
|
menuItemFactory: SymbolPickerMenuItemFactory
|
|
13737
13912
|
}
|
|
@@ -14701,7 +14876,7 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
14701
14876
|
};
|
|
14702
14877
|
}
|
|
14703
14878
|
attachPopupToRect(rect, popup, unitId) {
|
|
14704
|
-
const currentRender = this._renderManagerService.
|
|
14879
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
14705
14880
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14706
14881
|
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
14707
14882
|
const { position, position$, disposable } = this._createRectPositionObserver(rect, currentRender);
|
|
@@ -14730,7 +14905,7 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
14730
14905
|
* @returns disposable
|
|
14731
14906
|
*/
|
|
14732
14907
|
attachPopupToObject(targetObject, popup, unitId) {
|
|
14733
|
-
const currentRender = this._renderManagerService.
|
|
14908
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
14734
14909
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14735
14910
|
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
14736
14911
|
const { position, position$, disposable } = this._createObjectPositionObserver(targetObject, currentRender);
|
|
@@ -14762,7 +14937,7 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
14762
14937
|
attachPopupToRange(range, popup, unitId) {
|
|
14763
14938
|
if (!this._univerInstanceService.getUnit(unitId)) throw new Error(`Document not found, unitId: ${unitId}`);
|
|
14764
14939
|
const { direction = "top", multipleDirection } = popup;
|
|
14765
|
-
const currentRender = this._renderManagerService.
|
|
14940
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
14766
14941
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14767
14942
|
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
14768
14943
|
const { positions: bounds, positions$: bounds$, disposable } = this._createRangePositionObserver(range, currentRender);
|
|
@@ -15165,12 +15340,13 @@ let DocEventManagerService = class DocEventManagerService extends _univerjs_core
|
|
|
15165
15340
|
const customRanges = (_this$_context$unit$g = (_this$_context$unit$g2 = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) === null || _this$_context$unit$g2 === void 0 || (_this$_context$unit$g2 = _this$_context$unit$g2.getBody()) === null || _this$_context$unit$g2 === void 0 ? void 0 : _this$_context$unit$g2.customRanges) !== null && _this$_context$unit$g !== void 0 ? _this$_context$unit$g : [];
|
|
15166
15341
|
const layouts = [];
|
|
15167
15342
|
customRanges.forEach((range) => {
|
|
15168
|
-
const
|
|
15343
|
+
const textRange = {
|
|
15169
15344
|
startOffset: range.startIndex,
|
|
15170
15345
|
endOffset: range.endIndex + 1,
|
|
15171
15346
|
collapsed: false,
|
|
15172
15347
|
segmentId
|
|
15173
|
-
}
|
|
15348
|
+
};
|
|
15349
|
+
const rects = calcDocRangePositions$1(textRange, this._documents, this._skeleton, segmentPage);
|
|
15174
15350
|
if (!rects) return null;
|
|
15175
15351
|
layouts.push({
|
|
15176
15352
|
customRange: range,
|
|
@@ -15631,7 +15807,7 @@ function DocSideMenuContent() {
|
|
|
15631
15807
|
const fullDataStream = (_documentData$body$da = documentData === null || documentData === void 0 || (_documentData$body = documentData.body) === null || _documentData$body === void 0 ? void 0 : _documentData$body.dataStream) !== null && _documentData$body$da !== void 0 ? _documentData$body$da : "";
|
|
15632
15808
|
const [activeId, setActiveId] = (0, react.useState)(void 0);
|
|
15633
15809
|
const unitId = (_currentDoc$getUnitId = currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getUnitId()) !== null && _currentDoc$getUnitId !== void 0 ? _currentDoc$getUnitId : "";
|
|
15634
|
-
const renderer = renderManagerService.
|
|
15810
|
+
const renderer = renderManagerService.getRenderUnitById(unitId);
|
|
15635
15811
|
const title = documentData === null || documentData === void 0 ? void 0 : documentData.title;
|
|
15636
15812
|
const docEventManagerService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocEventManagerService);
|
|
15637
15813
|
const paragraphBounds = docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.paragraphBounds;
|
|
@@ -15673,7 +15849,8 @@ function DocSideMenuContent() {
|
|
|
15673
15849
|
}).filter((item) => item === null || item === void 0 ? void 0 : item.text);
|
|
15674
15850
|
const handleScroll = (0, _univerjs_ui.useEvent)((params) => {
|
|
15675
15851
|
const scrollTop = params.viewportScrollY;
|
|
15676
|
-
const
|
|
15852
|
+
const bottom = scrollTop + canvasHeight / scaleY;
|
|
15853
|
+
const activeId = findActiveHeading(paragraphBounds, paragraphMap, scrollTop, bottom);
|
|
15677
15854
|
if (activeId) setActiveId(activeId);
|
|
15678
15855
|
});
|
|
15679
15856
|
const menus = (paragraphMenus === null || paragraphMenus === void 0 ? void 0 : paragraphMenus.find((p) => p.isTitle)) ? paragraphMenus : [...title ? [{
|
|
@@ -15800,7 +15977,7 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
15800
15977
|
_initFocusHandler() {
|
|
15801
15978
|
this.disposeWithMe(this._layoutService.registerFocusHandler(_univerjs_core.UniverInstanceType.UNIVER_DOC, (unitId) => {
|
|
15802
15979
|
if (this._shouldPreserveEmbedFocus(unitId)) return;
|
|
15803
|
-
this._injector.get(_univerjs_engine_render.IRenderManagerService).
|
|
15980
|
+
this._injector.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(unitId).with(DocSelectionRenderService).focus();
|
|
15804
15981
|
}));
|
|
15805
15982
|
}
|
|
15806
15983
|
_shouldPreserveEmbedFocus(unitId) {
|
|
@@ -16056,7 +16233,8 @@ function resolveDocsCustomBlockRenderViewport(params) {
|
|
|
16056
16233
|
width: layoutWidth
|
|
16057
16234
|
};
|
|
16058
16235
|
}
|
|
16059
|
-
const
|
|
16236
|
+
const scale = params.scale && params.scale > 0 ? params.scale : 1;
|
|
16237
|
+
const inset = MODERN_DOCS_CUSTOM_BLOCK_VIEWPORT_INSET / scale;
|
|
16060
16238
|
const docsLeft = (_params$docsLeft = params.docsLeft) !== null && _params$docsLeft !== void 0 ? _params$docsLeft : 0;
|
|
16061
16239
|
const fallbackViewportLeft = docsLeft + inset;
|
|
16062
16240
|
const fallbackViewportWidth = Math.max(0, pageWidth - inset * 2);
|
|
@@ -16082,7 +16260,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
|
|
|
16082
16260
|
//#endregion
|
|
16083
16261
|
//#region package.json
|
|
16084
16262
|
var name = "@univerjs/docs-ui";
|
|
16085
|
-
var version = "1.0.0-alpha.
|
|
16263
|
+
var version = "1.0.0-alpha.8";
|
|
16086
16264
|
|
|
16087
16265
|
//#endregion
|
|
16088
16266
|
//#region src/commands/commands/doc-paragraph-setting.command.ts
|
|
@@ -16254,7 +16432,7 @@ function getSegmentId(documentStyle, editArea, pageIndex, page) {
|
|
|
16254
16432
|
}
|
|
16255
16433
|
const DocHeaderFooterOptions = (props) => {
|
|
16256
16434
|
var _segmentContext$segme, _segmentContext$segme2;
|
|
16257
|
-
const docSelectionRenderService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService).
|
|
16435
|
+
const docSelectionRenderService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(props.unitId).with(DocSelectionRenderService);
|
|
16258
16436
|
const segmentContext = (0, _univerjs_ui.useObservable)(docSelectionRenderService.segmentContext$, {
|
|
16259
16437
|
segmentId: docSelectionRenderService.getSegment(),
|
|
16260
16438
|
segmentPage: docSelectionRenderService.getSegmentPage()
|
|
@@ -16269,12 +16447,12 @@ function DocHeaderFooterOptionsContent(props) {
|
|
|
16269
16447
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
16270
16448
|
const layoutService = (0, _univerjs_ui.useDependency)(_univerjs_ui.ILayoutService);
|
|
16271
16449
|
const { unitId } = props;
|
|
16272
|
-
const docSelectionRenderService = renderManagerService.
|
|
16450
|
+
const docSelectionRenderService = renderManagerService.getRenderUnitById(unitId).with(DocSelectionRenderService);
|
|
16273
16451
|
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
16274
16452
|
const getCurrentSectionContext = () => {
|
|
16275
16453
|
var _renderManagerService, _docSkeletonManagerSe;
|
|
16276
16454
|
const snapshot = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot();
|
|
16277
|
-
const docSkeletonManagerService = (_renderManagerService = renderManagerService.
|
|
16455
|
+
const docSkeletonManagerService = (_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService);
|
|
16278
16456
|
const page = docSkeletonManagerService === null || docSkeletonManagerService === void 0 || (_docSkeletonManagerSe = docSkeletonManagerService.getSkeleton) === null || _docSkeletonManagerSe === void 0 || (_docSkeletonManagerSe = _docSkeletonManagerSe.call(docSkeletonManagerService)) === null || _docSkeletonManagerSe === void 0 || (_docSkeletonManagerSe = _docSkeletonManagerSe.getSkeletonData()) === null || _docSkeletonManagerSe === void 0 ? void 0 : _docSkeletonManagerSe.pages[docSelectionRenderService.getSegmentPage()];
|
|
16279
16457
|
return snapshot == null ? void 0 : {
|
|
16280
16458
|
...getDocPageSectionContext(snapshot, page),
|
|
@@ -16292,7 +16470,7 @@ function DocHeaderFooterOptionsContent(props) {
|
|
|
16292
16470
|
};
|
|
16293
16471
|
});
|
|
16294
16472
|
const sectionContext = getCurrentSectionContext();
|
|
16295
|
-
const referenceKey = (0, _univerjs_core.getSectionHeaderFooterReferenceKey)(((_renderManagerService2 = renderManagerService.
|
|
16473
|
+
const referenceKey = (0, _univerjs_core.getSectionHeaderFooterReferenceKey)(((_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", getHeaderFooterVariant((_sectionContext$confi = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config) !== null && _sectionContext$confi !== void 0 ? _sectionContext$confi : {}, docSelectionRenderService.getSegmentPage(), sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page));
|
|
16296
16474
|
const canLinkToPrevious = ((_sectionContext$secti = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionIndex) !== null && _sectionContext$secti !== void 0 ? _sectionContext$secti : -1) > 0;
|
|
16297
16475
|
const [linkedToPrevious, setLinkedToPrevious] = (0, react.useState)(canLinkToPrevious && !(sectionContext === null || sectionContext === void 0 || (_sectionContext$secti2 = sectionContext.section) === null || _sectionContext$secti2 === void 0 ? void 0 : _sectionContext$secti2[referenceKey]));
|
|
16298
16476
|
const handleCheckboxChange = (val, type) => {
|
|
@@ -16303,7 +16481,7 @@ function DocHeaderFooterOptionsContent(props) {
|
|
|
16303
16481
|
}));
|
|
16304
16482
|
const sectionContext = getCurrentSectionContext();
|
|
16305
16483
|
const documentStyle = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config;
|
|
16306
|
-
const docSkeletonManagerService = (_renderManagerService3 = renderManagerService.
|
|
16484
|
+
const docSkeletonManagerService = (_renderManagerService3 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService3 === void 0 ? void 0 : _renderManagerService3.with(_univerjs_docs.DocSkeletonManagerService);
|
|
16307
16485
|
const viewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
16308
16486
|
if (documentStyle == null || viewModel == null) return;
|
|
16309
16487
|
const editArea = viewModel.getEditArea();
|
|
@@ -16368,7 +16546,7 @@ function DocHeaderFooterOptionsContent(props) {
|
|
|
16368
16546
|
var _renderManagerService4;
|
|
16369
16547
|
const context = getCurrentSectionContext();
|
|
16370
16548
|
if (!(context === null || context === void 0 ? void 0 : context.sectionId) || context.sectionIndex <= 0 || !docDataModel) return;
|
|
16371
|
-
const kind = ((_renderManagerService4 = renderManagerService.
|
|
16549
|
+
const kind = ((_renderManagerService4 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService4 === void 0 || (_renderManagerService4 = _renderManagerService4.with(_univerjs_docs.DocSkeletonManagerService)) === null || _renderManagerService4 === void 0 || (_renderManagerService4 = _renderManagerService4.getViewModel()) === null || _renderManagerService4 === void 0 ? void 0 : _renderManagerService4.getEditArea()) === _univerjs_engine_render.DocumentEditArea.FOOTER ? "footer" : "header";
|
|
16372
16550
|
const currentVariant = getHeaderFooterVariant(context.config, docSelectionRenderService.getSegmentPage(), context.page);
|
|
16373
16551
|
const key = (0, _univerjs_core.getSectionHeaderFooterReferenceKey)(kind, currentVariant);
|
|
16374
16552
|
const segmentId = (0, _univerjs_core.generateRandomId)(6);
|
|
@@ -16858,7 +17036,7 @@ const useFirstParagraphLineSpacing = (paragraph) => {
|
|
|
16858
17036
|
var _renderManagerService;
|
|
16859
17037
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
16860
17038
|
if (!docDataModel) return;
|
|
16861
|
-
return (_renderManagerService = renderManagerService.
|
|
17039
|
+
return (_renderManagerService = renderManagerService.getRenderUnitById(docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId())) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
16862
17040
|
}, []);
|
|
16863
17041
|
const stateChange$ = (0, react.useMemo)(() => new rxjs.BehaviorSubject({}), []);
|
|
16864
17042
|
const [spacingRule, setSpacingRuleInternal] = (0, react.useState)(() => {
|
|
@@ -16887,7 +17065,8 @@ const useFirstParagraphLineSpacing = (paragraph) => {
|
|
|
16887
17065
|
const divideNode = glyphNode === null || glyphNode === void 0 ? void 0 : glyphNode.parent;
|
|
16888
17066
|
const metrics = getLineSpacingMetrics(divideNode === null || divideNode === void 0 ? void 0 : divideNode.parent);
|
|
16889
17067
|
const nextStoredLineSpacing = convertLineSpacingForRuleChange(convertDisplayLineSpacingToStoredValue(lineSpacing, spacingRule), spacingRule, v, metrics);
|
|
16890
|
-
|
|
17068
|
+
const nextDisplayLineSpacing = convertStoredLineSpacingToDisplayValue(nextStoredLineSpacing, v);
|
|
17069
|
+
setLineSpacingInternal(nextDisplayLineSpacing);
|
|
16891
17070
|
setSpacingRuleInternal(v);
|
|
16892
17071
|
stateChange$.next({
|
|
16893
17072
|
spacingRule: v,
|
|
@@ -17930,9 +18109,6 @@ const PARAGRAPH_MENU_HOVER_OPEN_DELAY = 800;
|
|
|
17930
18109
|
const PARAGRAPH_MENU_HOVER_HIDE_DELAY = 240;
|
|
17931
18110
|
const PARAGRAPH_MENU_HOVER_BRIDGE_EDGE_OVERLAP = 12;
|
|
17932
18111
|
const PARAGRAPH_MENU_HOVER_BRIDGE_VERTICAL_PADDING = 8;
|
|
17933
|
-
function getParagraphMenuTriggerClassName(visible) {
|
|
17934
|
-
return (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-white 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-700 dark:!univer-bg-gray-900 dark:hover:!univer-bg-gray-800", { "univer-bg-gray-100 univer-shadow-md dark:!univer-bg-gray-800": visible });
|
|
17935
|
-
}
|
|
17936
18112
|
function shouldExecuteParagraphMenuMove(validatorService, context) {
|
|
17937
18113
|
return validatorService.canMoveBlock(context);
|
|
17938
18114
|
}
|
|
@@ -18416,7 +18592,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
18416
18592
|
const handledSlashRequestNonceRef = (0, react.useRef)(0);
|
|
18417
18593
|
const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
18418
18594
|
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
18419
|
-
const renderUnit = renderManagerService.
|
|
18595
|
+
const renderUnit = renderManagerService.getRenderUnitById(popup.unitId);
|
|
18420
18596
|
const doc = univerInstanceService.getUnit(popup.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
18421
18597
|
const docParagraphMenuService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocParagraphMenuService);
|
|
18422
18598
|
const docEventManagerService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocEventManagerService);
|
|
@@ -18455,10 +18631,11 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
18455
18631
|
const boundingRect = (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.getBoundingClientRect();
|
|
18456
18632
|
const left = ((_boundingRect$left = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.left) !== null && _boundingRect$left !== void 0 ? _boundingRect$left : 0) - 4;
|
|
18457
18633
|
const right = (_boundingRect$right = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.right) !== null && _boundingRect$right !== void 0 ? _boundingRect$right : 0;
|
|
18634
|
+
const viewportWidth = (_anchorRef$current$ow = (_anchorRef$current2 = anchorRef.current) === null || _anchorRef$current2 === void 0 || (_anchorRef$current2 = _anchorRef$current2.ownerDocument.defaultView) === null || _anchorRef$current2 === void 0 ? void 0 : _anchorRef$current2.innerWidth) !== null && _anchorRef$current$ow !== void 0 ? _anchorRef$current$ow : window.innerWidth;
|
|
18458
18635
|
setMenuDirection(getParagraphMenuPopupDirection(left, 212, 8, {
|
|
18459
18636
|
anchorRight: right,
|
|
18460
18637
|
direction,
|
|
18461
|
-
viewportWidth
|
|
18638
|
+
viewportWidth
|
|
18462
18639
|
}));
|
|
18463
18640
|
const nextAnchorRect = {
|
|
18464
18641
|
left,
|
|
@@ -18492,10 +18669,11 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
18492
18669
|
clearHideTimer();
|
|
18493
18670
|
const latestTarget = (_docParagraphMenuServ = docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) !== null && _docParagraphMenuServ !== void 0 ? _docParagraphMenuServ : activeTarget;
|
|
18494
18671
|
setParagraphMenuInteractionActive(docParagraphMenuService, true);
|
|
18495
|
-
|
|
18672
|
+
const targetRange = latestTarget ? {
|
|
18496
18673
|
...latestTarget.menuRange,
|
|
18497
18674
|
segmentId: activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId
|
|
18498
18675
|
} : getParagraphMenuTargetRange(activeParagraphBound);
|
|
18676
|
+
targetRangeRef.current = targetRange;
|
|
18499
18677
|
updateAnchorRect();
|
|
18500
18678
|
setOpenMode(mode);
|
|
18501
18679
|
setVisible(true);
|
|
@@ -18523,7 +18701,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
18523
18701
|
};
|
|
18524
18702
|
const replaceSelection = (range) => {
|
|
18525
18703
|
if (!range) return;
|
|
18526
|
-
docSelectionManagerService.
|
|
18704
|
+
docSelectionManagerService.replaceDocRanges([range], void 0, false);
|
|
18527
18705
|
};
|
|
18528
18706
|
const getCurrentTextRangesSnapshot = () => {
|
|
18529
18707
|
var _docSelectionManagerS;
|
|
@@ -18531,7 +18709,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
18531
18709
|
};
|
|
18532
18710
|
const restoreTextRanges = (ranges) => {
|
|
18533
18711
|
if (!ranges) return;
|
|
18534
|
-
docSelectionManagerService.
|
|
18712
|
+
docSelectionManagerService.replaceDocRanges(ranges, void 0, false);
|
|
18535
18713
|
};
|
|
18536
18714
|
const executeResolvedCommand = (option, targetRange) => {
|
|
18537
18715
|
const resolved = getParagraphMenuResolvedCommand(option, targetRange);
|
|
@@ -18690,7 +18868,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
18690
18868
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
18691
18869
|
"data-u-comp": "paragraph-menu",
|
|
18692
18870
|
ref: anchorRef,
|
|
18693
|
-
className:
|
|
18871
|
+
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-white 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-700 dark:!univer-bg-gray-900 dark:hover:!univer-bg-gray-800", { "univer-bg-gray-100 univer-shadow-md dark:!univer-bg-gray-800": visible }),
|
|
18694
18872
|
onMouseEnter: (e) => {
|
|
18695
18873
|
var _popup$onPointerEnter;
|
|
18696
18874
|
(_popup$onPointerEnter = popup.onPointerEnter) === null || _popup$onPointerEnter === void 0 || _popup$onPointerEnter.call(popup, e);
|
|
@@ -18862,13 +19040,13 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
18862
19040
|
return;
|
|
18863
19041
|
}
|
|
18864
19042
|
if (commandId === DocPasteCommand.id) {
|
|
18865
|
-
docSelectionManagerService.
|
|
19043
|
+
docSelectionManagerService.replaceDocRanges([afterTableRange], void 0, false);
|
|
18866
19044
|
await commandService.executeCommand(DocPasteCommand.id);
|
|
18867
19045
|
finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
|
|
18868
19046
|
return;
|
|
18869
19047
|
}
|
|
18870
|
-
if (commandId === DocTableDeleteTableCommand.id) docSelectionManagerService.
|
|
18871
|
-
else if (params.id === "doc.menu.insert-bellow" || commandId !== "doc.menu.insert-bellow") docSelectionManagerService.
|
|
19048
|
+
if (commandId === DocTableDeleteTableCommand.id) docSelectionManagerService.replaceDocRanges([tableRange], void 0, false);
|
|
19049
|
+
else if (params.id === "doc.menu.insert-bellow" || commandId !== "doc.menu.insert-bellow") docSelectionManagerService.replaceDocRanges([afterTableRange], void 0, false);
|
|
18872
19050
|
if (commandService && commandId) commandService.executeCommand(commandId, commandId === DocTableDeleteTableCommand.id ? {
|
|
18873
19051
|
...commandParams,
|
|
18874
19052
|
targetRange: tableRange
|
|
@@ -18928,7 +19106,7 @@ function getSectionColumnGap(section) {
|
|
|
18928
19106
|
var _section$columnProper2, _section$columnProper3;
|
|
18929
19107
|
return (_section$columnProper2 = (_section$columnProper3 = section.columnProperties) === null || _section$columnProper3 === void 0 || (_section$columnProper3 = _section$columnProper3[0]) === null || _section$columnProper3 === void 0 ? void 0 : _section$columnProper3.paddingEnd) !== null && _section$columnProper2 !== void 0 ? _section$columnProper2 : DEFAULT_SECTION_COLUMN_GAP;
|
|
18930
19108
|
}
|
|
18931
|
-
function getSectionSettingValues(sections) {
|
|
19109
|
+
function getSectionSettingValues(sections, documentStyle) {
|
|
18932
19110
|
return {
|
|
18933
19111
|
columnCount: getCommonValue(sections.map(getSectionColumnCount)),
|
|
18934
19112
|
columnGap: getCommonValue(sections.map(getSectionColumnGap)),
|
|
@@ -18939,6 +19117,38 @@ function getSectionSettingValues(sections) {
|
|
|
18939
19117
|
sectionType: getCommonValue(sections.map((section) => {
|
|
18940
19118
|
var _section$sectionType;
|
|
18941
19119
|
return (_section$sectionType = section.sectionType) !== null && _section$sectionType !== void 0 ? _section$sectionType : _univerjs_core.SectionType.SECTION_TYPE_UNSPECIFIED;
|
|
19120
|
+
})),
|
|
19121
|
+
pageWidth: getCommonValue(sections.map((section) => {
|
|
19122
|
+
var _section$pageSize$wid, _section$pageSize, _documentStyle$pageSi;
|
|
19123
|
+
return (_section$pageSize$wid = (_section$pageSize = section.pageSize) === null || _section$pageSize === void 0 ? void 0 : _section$pageSize.width) !== null && _section$pageSize$wid !== void 0 ? _section$pageSize$wid : (_documentStyle$pageSi = documentStyle.pageSize) === null || _documentStyle$pageSi === void 0 ? void 0 : _documentStyle$pageSi.width;
|
|
19124
|
+
})),
|
|
19125
|
+
pageHeight: getCommonValue(sections.map((section) => {
|
|
19126
|
+
var _section$pageSize$hei, _section$pageSize2, _documentStyle$pageSi2;
|
|
19127
|
+
return (_section$pageSize$hei = (_section$pageSize2 = section.pageSize) === null || _section$pageSize2 === void 0 ? void 0 : _section$pageSize2.height) !== null && _section$pageSize$hei !== void 0 ? _section$pageSize$hei : (_documentStyle$pageSi2 = documentStyle.pageSize) === null || _documentStyle$pageSi2 === void 0 ? void 0 : _documentStyle$pageSi2.height;
|
|
19128
|
+
})),
|
|
19129
|
+
pageOrient: getCommonValue(sections.map((section) => {
|
|
19130
|
+
var _section$pageOrient;
|
|
19131
|
+
return (_section$pageOrient = section.pageOrient) !== null && _section$pageOrient !== void 0 ? _section$pageOrient : documentStyle.pageOrient;
|
|
19132
|
+
})),
|
|
19133
|
+
marginTop: getCommonValue(sections.map((section) => {
|
|
19134
|
+
var _ref, _section$marginTop;
|
|
19135
|
+
return (_ref = (_section$marginTop = section.marginTop) !== null && _section$marginTop !== void 0 ? _section$marginTop : documentStyle.marginTop) !== null && _ref !== void 0 ? _ref : 0;
|
|
19136
|
+
})),
|
|
19137
|
+
marginBottom: getCommonValue(sections.map((section) => {
|
|
19138
|
+
var _ref2, _section$marginBottom;
|
|
19139
|
+
return (_ref2 = (_section$marginBottom = section.marginBottom) !== null && _section$marginBottom !== void 0 ? _section$marginBottom : documentStyle.marginBottom) !== null && _ref2 !== void 0 ? _ref2 : 0;
|
|
19140
|
+
})),
|
|
19141
|
+
marginLeft: getCommonValue(sections.map((section) => {
|
|
19142
|
+
var _ref3, _section$marginLeft;
|
|
19143
|
+
return (_ref3 = (_section$marginLeft = section.marginLeft) !== null && _section$marginLeft !== void 0 ? _section$marginLeft : documentStyle.marginLeft) !== null && _ref3 !== void 0 ? _ref3 : 0;
|
|
19144
|
+
})),
|
|
19145
|
+
marginRight: getCommonValue(sections.map((section) => {
|
|
19146
|
+
var _ref4, _section$marginRight;
|
|
19147
|
+
return (_ref4 = (_section$marginRight = section.marginRight) !== null && _section$marginRight !== void 0 ? _section$marginRight : documentStyle.marginRight) !== null && _ref4 !== void 0 ? _ref4 : 0;
|
|
19148
|
+
})),
|
|
19149
|
+
pageNumberStart: getCommonValue(sections.map((section) => {
|
|
19150
|
+
var _ref5, _section$pageNumberSt;
|
|
19151
|
+
return (_ref5 = (_section$pageNumberSt = section.pageNumberStart) !== null && _section$pageNumberSt !== void 0 ? _section$pageNumberSt : documentStyle.pageNumberStart) !== null && _ref5 !== void 0 ? _ref5 : 1;
|
|
18942
19152
|
}))
|
|
18943
19153
|
};
|
|
18944
19154
|
}
|
|
@@ -18952,6 +19162,23 @@ function createSectionColumnUpdates(sections, documentStyle, change) {
|
|
|
18952
19162
|
};
|
|
18953
19163
|
});
|
|
18954
19164
|
}
|
|
19165
|
+
function createSectionOrientationUpdates(sections, documentStyle, pageOrient) {
|
|
19166
|
+
return sections.map((section) => {
|
|
19167
|
+
var _ref6, _section$pageOrient2, _section$pageSize3;
|
|
19168
|
+
const currentOrient = (_ref6 = (_section$pageOrient2 = section.pageOrient) !== null && _section$pageOrient2 !== void 0 ? _section$pageOrient2 : documentStyle.pageOrient) !== null && _ref6 !== void 0 ? _ref6 : _univerjs_core.PageOrientType.PORTRAIT;
|
|
19169
|
+
const currentPageSize = (_section$pageSize3 = section.pageSize) !== null && _section$pageSize3 !== void 0 ? _section$pageSize3 : documentStyle.pageSize;
|
|
19170
|
+
return {
|
|
19171
|
+
sectionId: section.sectionId,
|
|
19172
|
+
config: {
|
|
19173
|
+
pageOrient,
|
|
19174
|
+
...currentOrient !== pageOrient && (currentPageSize === null || currentPageSize === void 0 ? void 0 : currentPageSize.width) != null && currentPageSize.height != null ? { pageSize: {
|
|
19175
|
+
width: currentPageSize.height,
|
|
19176
|
+
height: currentPageSize.width
|
|
19177
|
+
} } : {}
|
|
19178
|
+
}
|
|
19179
|
+
};
|
|
19180
|
+
});
|
|
19181
|
+
}
|
|
18955
19182
|
function getSelectedSections(documentDataModel, ranges) {
|
|
18956
19183
|
const body = documentDataModel.getBody();
|
|
18957
19184
|
if (!body || ranges.length === 0 || ranges.some((range) => Boolean(range.segmentId))) return [];
|
|
@@ -18965,14 +19192,24 @@ function getSelectedSections(documentDataModel, ranges) {
|
|
|
18965
19192
|
});
|
|
18966
19193
|
});
|
|
18967
19194
|
}
|
|
19195
|
+
function navigateToSection(controller, documentDataModel, sections, sectionId) {
|
|
19196
|
+
const index = sections.findIndex((section) => section.sectionId === sectionId);
|
|
19197
|
+
if (!documentDataModel || index < 0) return;
|
|
19198
|
+
controller.navigateToSectionEnd(documentDataModel.getUnitId(), index === 0 ? 0 : sections[index - 1].startIndex + 1, sections[index].startIndex);
|
|
19199
|
+
}
|
|
18968
19200
|
function useSectionSetting() {
|
|
19201
|
+
var _documentDataModel$ge;
|
|
18969
19202
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
18970
19203
|
const instanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
18971
19204
|
const selectionManager = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
19205
|
+
const controller = (0, _univerjs_ui.useDependency)(DocSectionSettingController);
|
|
18972
19206
|
const documentDataModel = (0, _univerjs_ui.useObservable)((0, react.useMemo)(() => instanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC), [instanceService]));
|
|
18973
19207
|
const resolveSections = () => (documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getDocumentStyle().documentFlavor) === _univerjs_core.DocumentFlavor.TRADITIONAL ? getSelectedSections(documentDataModel, selectionManager.getDocRanges()) : [];
|
|
18974
19208
|
const sections = (0, _univerjs_ui.useObservable)(documentDataModel ? () => (0, rxjs.combineLatest)([selectionManager.textSelection$.pipe((0, rxjs.startWith)(void 0)), documentDataModel.change$.pipe((0, rxjs.startWith)(void 0))]).pipe((0, rxjs.map)(resolveSections)) : null, resolveSections(), false, [documentDataModel, selectionManager]);
|
|
18975
|
-
const
|
|
19209
|
+
const documentStyle = (_documentDataModel$ge = documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getDocumentStyle()) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : {};
|
|
19210
|
+
const values = getSectionSettingValues(sections, documentStyle);
|
|
19211
|
+
const body = documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getBody();
|
|
19212
|
+
const allSections = (documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getDocumentStyle().documentFlavor) === _univerjs_core.DocumentFlavor.TRADITIONAL && body ? (0, _univerjs_docs.getTopLevelSectionBreaks)(body) : [];
|
|
18976
19213
|
const update = (updates) => {
|
|
18977
19214
|
if (!documentDataModel || updates.length === 0) return Promise.resolve(false);
|
|
18978
19215
|
return commandService.executeCommand(_univerjs_docs.UpdateDocumentSectionCommand.id, {
|
|
@@ -18987,7 +19224,15 @@ function useSectionSetting() {
|
|
|
18987
19224
|
return {
|
|
18988
19225
|
valid: Boolean(documentDataModel && sections.length > 0),
|
|
18989
19226
|
selectedCount: sections.length,
|
|
19227
|
+
sectionOptions: allSections.map((section, index) => ({
|
|
19228
|
+
label: `#${index + 1}`,
|
|
19229
|
+
value: section.sectionId
|
|
19230
|
+
})),
|
|
19231
|
+
selectedSectionId: sections.length === 1 ? sections[0].sectionId : void 0,
|
|
18990
19232
|
...values,
|
|
19233
|
+
selectSection(sectionId) {
|
|
19234
|
+
navigateToSection(controller, documentDataModel !== null && documentDataModel !== void 0 ? documentDataModel : void 0, allSections, sectionId);
|
|
19235
|
+
},
|
|
18991
19236
|
setColumnCount(value) {
|
|
18992
19237
|
const next = Math.max(1, Math.round(value));
|
|
18993
19238
|
return update(documentDataModel ? createSectionColumnUpdates(sections, documentDataModel.getDocumentStyle(), { columnCount: next }) : []);
|
|
@@ -19001,6 +19246,44 @@ function useSectionSetting() {
|
|
|
19001
19246
|
},
|
|
19002
19247
|
setSectionType(value) {
|
|
19003
19248
|
return updateAll({ sectionType: value });
|
|
19249
|
+
},
|
|
19250
|
+
setPageWidth(value) {
|
|
19251
|
+
return update(sections.map((section) => ({
|
|
19252
|
+
sectionId: section.sectionId,
|
|
19253
|
+
config: { pageSize: {
|
|
19254
|
+
...documentStyle.pageSize,
|
|
19255
|
+
...section.pageSize,
|
|
19256
|
+
width: Math.max(1, value)
|
|
19257
|
+
} }
|
|
19258
|
+
})));
|
|
19259
|
+
},
|
|
19260
|
+
setPageHeight(value) {
|
|
19261
|
+
return update(sections.map((section) => ({
|
|
19262
|
+
sectionId: section.sectionId,
|
|
19263
|
+
config: { pageSize: {
|
|
19264
|
+
...documentStyle.pageSize,
|
|
19265
|
+
...section.pageSize,
|
|
19266
|
+
height: Math.max(1, value)
|
|
19267
|
+
} }
|
|
19268
|
+
})));
|
|
19269
|
+
},
|
|
19270
|
+
setPageOrient(value) {
|
|
19271
|
+
return update(createSectionOrientationUpdates(sections, documentStyle, value));
|
|
19272
|
+
},
|
|
19273
|
+
setMarginTop(value) {
|
|
19274
|
+
return updateAll({ marginTop: Math.max(0, value) });
|
|
19275
|
+
},
|
|
19276
|
+
setMarginBottom(value) {
|
|
19277
|
+
return updateAll({ marginBottom: Math.max(0, value) });
|
|
19278
|
+
},
|
|
19279
|
+
setMarginLeft(value) {
|
|
19280
|
+
return updateAll({ marginLeft: Math.max(0, value) });
|
|
19281
|
+
},
|
|
19282
|
+
setMarginRight(value) {
|
|
19283
|
+
return updateAll({ marginRight: Math.max(0, value) });
|
|
19284
|
+
},
|
|
19285
|
+
setPageNumberStart(value) {
|
|
19286
|
+
return updateAll({ pageNumberStart: Math.max(1, Math.round(value)) });
|
|
19004
19287
|
}
|
|
19005
19288
|
};
|
|
19006
19289
|
}
|
|
@@ -19011,9 +19294,9 @@ function SettingRow(props) {
|
|
|
19011
19294
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
19012
19295
|
className: "univer-grid univer-min-h-8 univer-items-center univer-gap-3",
|
|
19013
19296
|
style: { gridTemplateColumns: "minmax(0, 1fr) minmax(140px, 160px)" },
|
|
19014
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
19297
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
19015
19298
|
className: "univer-min-w-0 univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-text-gray-100",
|
|
19016
|
-
children: props.label
|
|
19299
|
+
children: [props.label, props.unit]
|
|
19017
19300
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
19018
19301
|
className: "univer-w-full univer-min-w-0",
|
|
19019
19302
|
children: props.children
|
|
@@ -19021,27 +19304,11 @@ function SettingRow(props) {
|
|
|
19021
19304
|
});
|
|
19022
19305
|
}
|
|
19023
19306
|
function SectionSetting() {
|
|
19307
|
+
var _setting$selectedSect;
|
|
19024
19308
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
19025
19309
|
const controller = (0, _univerjs_ui.useDependency)(DocSectionSettingController);
|
|
19026
19310
|
const setting = useSectionSetting();
|
|
19027
|
-
|
|
19028
|
-
selectedSections: localeService.t("docs-ui.doc.sectionSetting.selectedSections", String(setting.selectedCount)),
|
|
19029
|
-
columnCount: localeService.t("docs-ui.doc.sectionSetting.columnCount"),
|
|
19030
|
-
columnGap: `${localeService.t("docs-ui.doc.sectionSetting.columnGap")}(px)`,
|
|
19031
|
-
columnSeparator: localeService.t("docs-ui.doc.sectionSetting.columnSeparator"),
|
|
19032
|
-
none: localeService.t("docs-ui.doc.sectionSetting.none"),
|
|
19033
|
-
betweenColumns: localeService.t("docs-ui.doc.sectionSetting.betweenColumns"),
|
|
19034
|
-
sectionStart: localeService.t("docs-ui.doc.sectionSetting.sectionStart"),
|
|
19035
|
-
unspecified: localeService.t("docs-ui.doc.sectionSetting.unspecified"),
|
|
19036
|
-
continuous: localeService.t("docs-ui.doc.sectionSetting.continuous"),
|
|
19037
|
-
nextPage: localeService.t("docs-ui.doc.sectionSetting.nextPage"),
|
|
19038
|
-
evenPage: localeService.t("docs-ui.doc.sectionSetting.evenPage"),
|
|
19039
|
-
oddPage: localeService.t("docs-ui.doc.sectionSetting.oddPage")
|
|
19040
|
-
}), [
|
|
19041
|
-
(0, _univerjs_ui.useObservable)(localeService.currentLocale$),
|
|
19042
|
-
localeService,
|
|
19043
|
-
setting.selectedCount
|
|
19044
|
-
]);
|
|
19311
|
+
(0, _univerjs_ui.useObservable)(localeService.currentLocale$);
|
|
19045
19312
|
(0, react.useEffect)(() => {
|
|
19046
19313
|
if (!setting.valid) controller.closePanel();
|
|
19047
19314
|
}, [controller, setting.valid]);
|
|
@@ -19050,13 +19317,27 @@ function SectionSetting() {
|
|
|
19050
19317
|
className: "univer-box-border univer-w-full",
|
|
19051
19318
|
children: [setting.selectedCount > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
19052
19319
|
className: "univer-mb-4 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-300",
|
|
19053
|
-
children:
|
|
19320
|
+
children: localeService.t("docs-ui.doc.sectionSetting.selectedSections", `${setting.selectedCount}`)
|
|
19054
19321
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
19055
19322
|
className: "univer-grid univer-gap-3",
|
|
19056
19323
|
children: [
|
|
19057
19324
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19058
|
-
label:
|
|
19325
|
+
label: localeService.t("docs-ui.doc.slider.sectionSetting"),
|
|
19326
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
19327
|
+
className: "univer-w-full",
|
|
19328
|
+
value: (_setting$selectedSect = setting.selectedSectionId) !== null && _setting$selectedSect !== void 0 ? _setting$selectedSect : "",
|
|
19329
|
+
options: [...setting.selectedSectionId == null ? [{
|
|
19330
|
+
label: localeService.t("docs-ui.doc.sectionSetting.multipleValues"),
|
|
19331
|
+
value: "",
|
|
19332
|
+
disabled: true
|
|
19333
|
+
}] : [], ...setting.sectionOptions],
|
|
19334
|
+
onChange: setting.selectSection
|
|
19335
|
+
})
|
|
19336
|
+
}),
|
|
19337
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19338
|
+
label: localeService.t("docs-ui.doc.sectionSetting.columnCount"),
|
|
19059
19339
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
19340
|
+
"aria-label": localeService.t("docs-ui.doc.sectionSetting.columnCount"),
|
|
19060
19341
|
className: "univer-w-full",
|
|
19061
19342
|
min: 1,
|
|
19062
19343
|
max: 12,
|
|
@@ -19067,8 +19348,10 @@ function SectionSetting() {
|
|
|
19067
19348
|
})
|
|
19068
19349
|
}),
|
|
19069
19350
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19070
|
-
label:
|
|
19351
|
+
label: localeService.t("docs-ui.doc.sectionSetting.columnGap"),
|
|
19352
|
+
unit: " (px)",
|
|
19071
19353
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
19354
|
+
"aria-label": localeService.t("docs-ui.doc.sectionSetting.columnGap"),
|
|
19072
19355
|
className: "univer-w-full",
|
|
19073
19356
|
min: 0,
|
|
19074
19357
|
max: 1e3,
|
|
@@ -19079,49 +19362,183 @@ function SectionSetting() {
|
|
|
19079
19362
|
})
|
|
19080
19363
|
}),
|
|
19081
19364
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19082
|
-
label:
|
|
19365
|
+
label: localeService.t("docs-ui.doc.sectionSetting.columnSeparator"),
|
|
19083
19366
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
19084
19367
|
className: "univer-w-full",
|
|
19085
|
-
value: setting.separatorType == null ? "" :
|
|
19086
|
-
options: [
|
|
19087
|
-
|
|
19088
|
-
|
|
19089
|
-
|
|
19090
|
-
|
|
19091
|
-
|
|
19092
|
-
|
|
19368
|
+
value: setting.separatorType == null ? "" : `${setting.separatorType}`,
|
|
19369
|
+
options: [
|
|
19370
|
+
...setting.separatorType == null ? [{
|
|
19371
|
+
label: localeService.t("docs-ui.doc.sectionSetting.multipleValues"),
|
|
19372
|
+
value: "",
|
|
19373
|
+
disabled: true
|
|
19374
|
+
}] : [],
|
|
19375
|
+
{
|
|
19376
|
+
label: localeService.t("docs-ui.doc.sectionSetting.none"),
|
|
19377
|
+
value: `${_univerjs_core.ColumnSeparatorType.NONE}`
|
|
19378
|
+
},
|
|
19379
|
+
{
|
|
19380
|
+
label: localeService.t("docs-ui.doc.sectionSetting.betweenColumns"),
|
|
19381
|
+
value: `${_univerjs_core.ColumnSeparatorType.BETWEEN_EACH_COLUMN}`
|
|
19382
|
+
}
|
|
19383
|
+
],
|
|
19093
19384
|
onChange: (value) => setting.setSeparatorType(Number(value))
|
|
19094
19385
|
})
|
|
19095
19386
|
}),
|
|
19096
19387
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19097
|
-
label:
|
|
19388
|
+
label: localeService.t("docs-ui.doc.sectionSetting.sectionStart"),
|
|
19098
19389
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
19099
19390
|
className: "univer-w-full",
|
|
19100
|
-
value: setting.sectionType == null ? "" :
|
|
19391
|
+
value: setting.sectionType == null ? "" : `${setting.sectionType}`,
|
|
19101
19392
|
options: [
|
|
19393
|
+
...setting.sectionType == null ? [{
|
|
19394
|
+
label: localeService.t("docs-ui.doc.sectionSetting.multipleValues"),
|
|
19395
|
+
value: "",
|
|
19396
|
+
disabled: true
|
|
19397
|
+
}] : [],
|
|
19398
|
+
{
|
|
19399
|
+
label: localeService.t("docs-ui.doc.sectionSetting.unspecified"),
|
|
19400
|
+
value: `${_univerjs_core.SectionType.SECTION_TYPE_UNSPECIFIED}`
|
|
19401
|
+
},
|
|
19102
19402
|
{
|
|
19103
|
-
label:
|
|
19104
|
-
value:
|
|
19403
|
+
label: localeService.t("docs-ui.doc.sectionSetting.continuous"),
|
|
19404
|
+
value: `${_univerjs_core.SectionType.CONTINUOUS}`
|
|
19105
19405
|
},
|
|
19106
19406
|
{
|
|
19107
|
-
label:
|
|
19108
|
-
value:
|
|
19407
|
+
label: localeService.t("docs-ui.doc.sectionSetting.nextColumn"),
|
|
19408
|
+
value: `${_univerjs_core.SectionType.NEXT_COLUMN}`
|
|
19109
19409
|
},
|
|
19110
19410
|
{
|
|
19111
|
-
label:
|
|
19112
|
-
value:
|
|
19411
|
+
label: localeService.t("docs-ui.doc.sectionSetting.nextPage"),
|
|
19412
|
+
value: `${_univerjs_core.SectionType.NEXT_PAGE}`
|
|
19113
19413
|
},
|
|
19114
19414
|
{
|
|
19115
|
-
label:
|
|
19116
|
-
value:
|
|
19415
|
+
label: localeService.t("docs-ui.doc.sectionSetting.evenPage"),
|
|
19416
|
+
value: `${_univerjs_core.SectionType.EVEN_PAGE}`
|
|
19117
19417
|
},
|
|
19118
19418
|
{
|
|
19119
|
-
label:
|
|
19120
|
-
value:
|
|
19419
|
+
label: localeService.t("docs-ui.doc.sectionSetting.oddPage"),
|
|
19420
|
+
value: `${_univerjs_core.SectionType.ODD_PAGE}`
|
|
19121
19421
|
}
|
|
19122
19422
|
],
|
|
19123
19423
|
onChange: (value) => setting.setSectionType(Number(value))
|
|
19124
19424
|
})
|
|
19425
|
+
}),
|
|
19426
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
19427
|
+
className: "univer-pt-2 univer-text-sm univer-font-medium",
|
|
19428
|
+
children: localeService.t("docs-ui.doc.sectionSetting.pageSetup")
|
|
19429
|
+
}),
|
|
19430
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19431
|
+
label: localeService.t("docs-ui.doc.sectionSetting.pageWidth"),
|
|
19432
|
+
unit: " (px)",
|
|
19433
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
19434
|
+
"aria-label": localeService.t("docs-ui.doc.sectionSetting.pageWidth"),
|
|
19435
|
+
className: "univer-w-full",
|
|
19436
|
+
min: 1,
|
|
19437
|
+
step: 1,
|
|
19438
|
+
precision: 1,
|
|
19439
|
+
value: setting.pageWidth,
|
|
19440
|
+
onChange: (value) => value != null && setting.setPageWidth(value)
|
|
19441
|
+
})
|
|
19442
|
+
}),
|
|
19443
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19444
|
+
label: localeService.t("docs-ui.doc.sectionSetting.pageHeight"),
|
|
19445
|
+
unit: " (px)",
|
|
19446
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
19447
|
+
"aria-label": localeService.t("docs-ui.doc.sectionSetting.pageHeight"),
|
|
19448
|
+
className: "univer-w-full",
|
|
19449
|
+
min: 1,
|
|
19450
|
+
step: 1,
|
|
19451
|
+
precision: 1,
|
|
19452
|
+
value: setting.pageHeight,
|
|
19453
|
+
onChange: (value) => value != null && setting.setPageHeight(value)
|
|
19454
|
+
})
|
|
19455
|
+
}),
|
|
19456
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19457
|
+
label: localeService.t("docs-ui.page-settings.orientation"),
|
|
19458
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
19459
|
+
className: "univer-w-full",
|
|
19460
|
+
value: setting.pageOrient == null ? "" : `${setting.pageOrient}`,
|
|
19461
|
+
options: [
|
|
19462
|
+
...setting.pageOrient == null ? [{
|
|
19463
|
+
label: localeService.t("docs-ui.doc.sectionSetting.multipleValues"),
|
|
19464
|
+
value: "",
|
|
19465
|
+
disabled: true
|
|
19466
|
+
}] : [],
|
|
19467
|
+
{
|
|
19468
|
+
label: localeService.t("docs-ui.page-settings.portrait"),
|
|
19469
|
+
value: `${_univerjs_core.PageOrientType.PORTRAIT}`
|
|
19470
|
+
},
|
|
19471
|
+
{
|
|
19472
|
+
label: localeService.t("docs-ui.page-settings.landscape"),
|
|
19473
|
+
value: `${_univerjs_core.PageOrientType.LANDSCAPE}`
|
|
19474
|
+
}
|
|
19475
|
+
],
|
|
19476
|
+
onChange: (value) => setting.setPageOrient(Number(value))
|
|
19477
|
+
})
|
|
19478
|
+
}),
|
|
19479
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19480
|
+
label: localeService.t("docs-ui.page-settings.top"),
|
|
19481
|
+
unit: " (px)",
|
|
19482
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
19483
|
+
"aria-label": localeService.t("docs-ui.page-settings.top"),
|
|
19484
|
+
className: "univer-w-full",
|
|
19485
|
+
min: 0,
|
|
19486
|
+
step: 1,
|
|
19487
|
+
precision: 1,
|
|
19488
|
+
value: setting.marginTop,
|
|
19489
|
+
onChange: (value) => value != null && setting.setMarginTop(value)
|
|
19490
|
+
})
|
|
19491
|
+
}),
|
|
19492
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19493
|
+
label: localeService.t("docs-ui.page-settings.bottom"),
|
|
19494
|
+
unit: " (px)",
|
|
19495
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
19496
|
+
"aria-label": localeService.t("docs-ui.page-settings.bottom"),
|
|
19497
|
+
className: "univer-w-full",
|
|
19498
|
+
min: 0,
|
|
19499
|
+
step: 1,
|
|
19500
|
+
precision: 1,
|
|
19501
|
+
value: setting.marginBottom,
|
|
19502
|
+
onChange: (value) => value != null && setting.setMarginBottom(value)
|
|
19503
|
+
})
|
|
19504
|
+
}),
|
|
19505
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19506
|
+
label: localeService.t("docs-ui.page-settings.left"),
|
|
19507
|
+
unit: " (px)",
|
|
19508
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
19509
|
+
"aria-label": localeService.t("docs-ui.page-settings.left"),
|
|
19510
|
+
className: "univer-w-full",
|
|
19511
|
+
min: 0,
|
|
19512
|
+
step: 1,
|
|
19513
|
+
precision: 1,
|
|
19514
|
+
value: setting.marginLeft,
|
|
19515
|
+
onChange: (value) => value != null && setting.setMarginLeft(value)
|
|
19516
|
+
})
|
|
19517
|
+
}),
|
|
19518
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19519
|
+
label: localeService.t("docs-ui.page-settings.right"),
|
|
19520
|
+
unit: " (px)",
|
|
19521
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
19522
|
+
"aria-label": localeService.t("docs-ui.page-settings.right"),
|
|
19523
|
+
className: "univer-w-full",
|
|
19524
|
+
min: 0,
|
|
19525
|
+
step: 1,
|
|
19526
|
+
precision: 1,
|
|
19527
|
+
value: setting.marginRight,
|
|
19528
|
+
onChange: (value) => value != null && setting.setMarginRight(value)
|
|
19529
|
+
})
|
|
19530
|
+
}),
|
|
19531
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
19532
|
+
label: localeService.t("docs-ui.doc.sectionSetting.pageNumberStart"),
|
|
19533
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
19534
|
+
"aria-label": localeService.t("docs-ui.doc.sectionSetting.pageNumberStart"),
|
|
19535
|
+
className: "univer-w-full",
|
|
19536
|
+
min: 1,
|
|
19537
|
+
step: 1,
|
|
19538
|
+
precision: 0,
|
|
19539
|
+
value: setting.pageNumberStart,
|
|
19540
|
+
onChange: (value) => value != null && setting.setPageNumberStart(value)
|
|
19541
|
+
})
|
|
19125
19542
|
})
|
|
19126
19543
|
]
|
|
19127
19544
|
})]
|
|
@@ -19226,6 +19643,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
19226
19643
|
AddImageIcon: _univerjs_icons.AddImageIcon,
|
|
19227
19644
|
BoldIcon: _univerjs_icons.BoldIcon,
|
|
19228
19645
|
CopyDoubleIcon: _univerjs_icons.CopyDoubleIcon,
|
|
19646
|
+
ColumnIcon: _univerjs_icons.ColumnIcon,
|
|
19229
19647
|
CutIcon: _univerjs_icons.CutIcon,
|
|
19230
19648
|
DeleteColumnDoubleIcon: _univerjs_icons.DeleteColumnDoubleIcon,
|
|
19231
19649
|
DeleteIcon: _univerjs_icons.DeleteIcon,
|
|
@@ -19367,7 +19785,7 @@ let DocAutoFormatController = class DocAutoFormatController extends _univerjs_co
|
|
|
19367
19785
|
match: (context) => {
|
|
19368
19786
|
const { selection, unit } = context;
|
|
19369
19787
|
const { startNodePosition, endNodePosition } = selection;
|
|
19370
|
-
const renderObject = this._renderManagerService.
|
|
19788
|
+
const renderObject = this._renderManagerService.getRenderUnitById(unit.getUnitId());
|
|
19371
19789
|
const skeleton = renderObject === null || renderObject === void 0 ? void 0 : renderObject.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
19372
19790
|
if (skeleton == null) return false;
|
|
19373
19791
|
if (startNodePosition && endNodePosition && isInSameTableCellData(skeleton, startNodePosition, endNodePosition)) return true;
|
|
@@ -19505,9 +19923,10 @@ var TextBubbleShape = class TextBubbleShape extends _univerjs_engine_render.Shap
|
|
|
19505
19923
|
ctx.save();
|
|
19506
19924
|
ctx.font = "13px Source Han Sans CN";
|
|
19507
19925
|
const textWidth = ctx.measureText(text).width;
|
|
19926
|
+
const realInfoWidth = Math.min(textWidth + 2 * 6, 200);
|
|
19508
19927
|
drawBubble(ctx, {
|
|
19509
19928
|
height: 18,
|
|
19510
|
-
width:
|
|
19929
|
+
width: realInfoWidth,
|
|
19511
19930
|
radius: 4,
|
|
19512
19931
|
fill: color,
|
|
19513
19932
|
evented: false
|
|
@@ -19828,13 +20247,14 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
19828
20247
|
}));
|
|
19829
20248
|
}
|
|
19830
20249
|
_handleShiftMoveSelection(direction, granularity = "character") {
|
|
19831
|
-
var
|
|
20250
|
+
var _docDataModel$getSelf, _body$dataStream$leng, _docDataModel$getCust;
|
|
19832
20251
|
const activeRange = this._textSelectionManagerService.getActiveTextRange();
|
|
19833
20252
|
const allRanges = this._textSelectionManagerService.getTextRanges();
|
|
19834
20253
|
const docDataModel = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
19835
20254
|
if (docDataModel == null) return;
|
|
19836
|
-
const
|
|
19837
|
-
const
|
|
20255
|
+
const currentRender = this._renderManagerService.getRenderUnitById(docDataModel.getUnitId());
|
|
20256
|
+
const skeleton = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
20257
|
+
const docObject = currentRender ? neoGetDocObject(currentRender) : null;
|
|
19838
20258
|
if (activeRange == null || skeleton == null || docObject == null) return;
|
|
19839
20259
|
const { startOffset, endOffset, style, collapsed, direction: rangeDirection, segmentId, startNodePosition, endNodePosition, segmentPage } = activeRange;
|
|
19840
20260
|
const normalizedSegmentId = segmentId !== null && segmentId !== void 0 ? segmentId : "";
|
|
@@ -19846,11 +20266,11 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
19846
20266
|
min = Math.min(min, range.startOffset);
|
|
19847
20267
|
max = Math.max(max, range.endOffset);
|
|
19848
20268
|
}
|
|
19849
|
-
this._textSelectionManagerService.
|
|
20269
|
+
this._textSelectionManagerService.replaceDocRanges([{
|
|
19850
20270
|
startOffset: direction === _univerjs_core.Direction.LEFT || direction === _univerjs_core.Direction.UP ? max : min,
|
|
19851
20271
|
endOffset: direction === _univerjs_core.Direction.LEFT || direction === _univerjs_core.Direction.UP ? min : max,
|
|
19852
20272
|
style
|
|
19853
|
-
}], false);
|
|
20273
|
+
}], void 0, false);
|
|
19854
20274
|
return;
|
|
19855
20275
|
}
|
|
19856
20276
|
const anchorOffset = collapsed ? startOffset : rangeDirection === _univerjs_core.RANGE_DIRECTION.FORWARD ? startOffset : endOffset;
|
|
@@ -19864,11 +20284,11 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
19864
20284
|
if (nextOffset == null || nextOffset === focusOffset) return;
|
|
19865
20285
|
const normalizedNextOffset = this._normalizeRenderableCursorOffset(skeleton, body.dataStream, customRanges, nextOffset, direction, normalizedSegmentId, normalizedSegmentPage);
|
|
19866
20286
|
if (normalizedNextOffset == null || normalizedNextOffset === focusOffset) return;
|
|
19867
|
-
this._textSelectionManagerService.
|
|
20287
|
+
this._textSelectionManagerService.replaceDocRanges([{
|
|
19868
20288
|
startOffset: anchorOffset,
|
|
19869
20289
|
endOffset: normalizedNextOffset,
|
|
19870
20290
|
style
|
|
19871
|
-
}], false);
|
|
20291
|
+
}], void 0, false);
|
|
19872
20292
|
this._scrollToFocusNodePosition(docDataModel.getUnitId(), normalizedNextOffset);
|
|
19873
20293
|
return;
|
|
19874
20294
|
}
|
|
@@ -19878,11 +20298,11 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
19878
20298
|
const curGlyph = skeleton.findNodeByCharIndex(focusOffset, segmentId, segmentPage);
|
|
19879
20299
|
focusOffset = direction === _univerjs_core.Direction.RIGHT ? focusOffset + curGlyph.count : focusOffset - ((_preGlyph$count = preGlyph === null || preGlyph === void 0 ? void 0 : preGlyph.count) !== null && _preGlyph$count !== void 0 ? _preGlyph$count : 0);
|
|
19880
20300
|
focusOffset = Math.min(dataStreamLength - 2, Math.max(0, focusOffset));
|
|
19881
|
-
this._textSelectionManagerService.
|
|
20301
|
+
this._textSelectionManagerService.replaceDocRanges([{
|
|
19882
20302
|
startOffset: anchorOffset,
|
|
19883
20303
|
endOffset: focusOffset,
|
|
19884
20304
|
style
|
|
19885
|
-
}], false);
|
|
20305
|
+
}], void 0, false);
|
|
19886
20306
|
this._scrollToFocusNodePosition(docDataModel.getUnitId(), focusOffset);
|
|
19887
20307
|
} else {
|
|
19888
20308
|
const focusGlyph = skeleton.findNodeByCharIndex(focusOffset, segmentId, segmentPage);
|
|
@@ -19892,32 +20312,33 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
19892
20312
|
if (newPos == null) {
|
|
19893
20313
|
const newFocusOffset = this._normalizeRenderableCursorOffset(skeleton, body.dataStream, customRanges, direction === _univerjs_core.Direction.UP ? 0 : dataStreamLength - 2, direction, normalizedSegmentId, normalizedSegmentPage);
|
|
19894
20314
|
if (newFocusOffset == null || newFocusOffset === focusOffset) return;
|
|
19895
|
-
this._textSelectionManagerService.
|
|
20315
|
+
this._textSelectionManagerService.replaceDocRanges([{
|
|
19896
20316
|
startOffset: anchorOffset,
|
|
19897
20317
|
endOffset: newFocusOffset,
|
|
19898
20318
|
style
|
|
19899
|
-
}], false);
|
|
20319
|
+
}], void 0, false);
|
|
19900
20320
|
return;
|
|
19901
20321
|
}
|
|
19902
20322
|
const newActiveRange = new NodePositionConvertToCursor(documentOffsetConfig, skeleton).getRangePointData(newPos, newPos).cursorList[0];
|
|
19903
20323
|
const newFocusOffset = this._normalizeRenderableCursorOffset(skeleton, body.dataStream, customRanges, newActiveRange.endOffset, direction, normalizedSegmentId, normalizedSegmentPage);
|
|
19904
20324
|
if (newFocusOffset == null || newFocusOffset === focusOffset) return;
|
|
19905
|
-
this._textSelectionManagerService.
|
|
20325
|
+
this._textSelectionManagerService.replaceDocRanges([{
|
|
19906
20326
|
startOffset: anchorOffset,
|
|
19907
20327
|
endOffset: newFocusOffset,
|
|
19908
20328
|
style
|
|
19909
|
-
}], false);
|
|
20329
|
+
}], void 0, false);
|
|
19910
20330
|
this._scrollToFocusNodePosition(docDataModel.getUnitId(), newFocusOffset);
|
|
19911
20331
|
}
|
|
19912
20332
|
}
|
|
19913
20333
|
_handleMoveCursor(direction, granularity = "character") {
|
|
19914
|
-
var
|
|
20334
|
+
var _docDataModel$getSelf2, _body$dataStream$leng2, _docDataModel$getCust2;
|
|
19915
20335
|
const activeRange = this._textSelectionManagerService.getActiveTextRange();
|
|
19916
20336
|
const allRanges = this._textSelectionManagerService.getTextRanges();
|
|
19917
20337
|
const docDataModel = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
19918
20338
|
if (docDataModel == null) return false;
|
|
19919
|
-
const
|
|
19920
|
-
const
|
|
20339
|
+
const currentRender = this._renderManagerService.getRenderUnitById(docDataModel.getUnitId());
|
|
20340
|
+
const skeleton = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
20341
|
+
const docObject = currentRender ? neoGetDocObject(currentRender) : null;
|
|
19921
20342
|
if (activeRange == null || skeleton == null || docObject == null || allRanges == null) return;
|
|
19922
20343
|
const { startOffset, endOffset, style, collapsed, segmentId, startNodePosition, endNodePosition, segmentPage } = activeRange;
|
|
19923
20344
|
const normalizedSegmentId = segmentId !== null && segmentId !== void 0 ? segmentId : "";
|
|
@@ -19941,11 +20362,11 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
19941
20362
|
if (cursor == null) return;
|
|
19942
20363
|
cursor = this._normalizeRenderableCursorOffset(skeleton, body.dataStream, customRanges, cursor, direction, normalizedSegmentId, normalizedSegmentPage);
|
|
19943
20364
|
if (cursor == null) return;
|
|
19944
|
-
this._textSelectionManagerService.
|
|
20365
|
+
this._textSelectionManagerService.replaceDocRanges([{
|
|
19945
20366
|
startOffset: cursor,
|
|
19946
20367
|
endOffset: cursor,
|
|
19947
20368
|
style
|
|
19948
|
-
}], false);
|
|
20369
|
+
}], void 0, false);
|
|
19949
20370
|
this._scrollToFocusNodePosition(docDataModel.getUnitId(), cursor);
|
|
19950
20371
|
return;
|
|
19951
20372
|
}
|
|
@@ -19974,11 +20395,11 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
19974
20395
|
cursor = this._normalizeCursorOffset(body.dataStream, customRanges, cursor, direction);
|
|
19975
20396
|
const normalizedCursor = this._normalizeRenderableCursorOffset(skeleton, body.dataStream, customRanges, cursor, direction, normalizedSegmentId, normalizedSegmentPage);
|
|
19976
20397
|
if (normalizedCursor == null) return;
|
|
19977
|
-
this._textSelectionManagerService.
|
|
20398
|
+
this._textSelectionManagerService.replaceDocRanges([{
|
|
19978
20399
|
startOffset: normalizedCursor,
|
|
19979
20400
|
endOffset: normalizedCursor,
|
|
19980
20401
|
style
|
|
19981
|
-
}], false);
|
|
20402
|
+
}], void 0, false);
|
|
19982
20403
|
this._scrollToFocusNodePosition(docDataModel.getUnitId(), normalizedCursor);
|
|
19983
20404
|
} else {
|
|
19984
20405
|
const startNode = skeleton.findNodeByCharIndex(startOffset, segmentId, segmentPage);
|
|
@@ -19990,21 +20411,21 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
19990
20411
|
if (collapsed) cursor = this._normalizeRenderableCursorOffset(skeleton, body.dataStream, customRanges, direction === _univerjs_core.Direction.UP ? 0 : dataStreamLength - 2, direction, normalizedSegmentId, normalizedSegmentPage);
|
|
19991
20412
|
else cursor = this._normalizeRenderableCursorOffset(skeleton, body.dataStream, customRanges, direction === _univerjs_core.Direction.UP ? startOffset : endOffset, direction, normalizedSegmentId, normalizedSegmentPage);
|
|
19992
20413
|
if (cursor == null) return;
|
|
19993
|
-
this._textSelectionManagerService.
|
|
20414
|
+
this._textSelectionManagerService.replaceDocRanges([{
|
|
19994
20415
|
startOffset: cursor,
|
|
19995
20416
|
endOffset: cursor,
|
|
19996
20417
|
style
|
|
19997
|
-
}], false);
|
|
20418
|
+
}], void 0, false);
|
|
19998
20419
|
return;
|
|
19999
20420
|
}
|
|
20000
20421
|
const newActiveRange = new NodePositionConvertToCursor(documentOffsetConfig, skeleton).getRangePointData(newPos, newPos).cursorList[0];
|
|
20001
20422
|
const cursor = this._normalizeRenderableCursorOffset(skeleton, body.dataStream, customRanges, newActiveRange.endOffset, direction, normalizedSegmentId, normalizedSegmentPage);
|
|
20002
20423
|
if (cursor == null) return;
|
|
20003
|
-
this._textSelectionManagerService.
|
|
20424
|
+
this._textSelectionManagerService.replaceDocRanges([{
|
|
20004
20425
|
startOffset: cursor,
|
|
20005
20426
|
endOffset: cursor,
|
|
20006
20427
|
style
|
|
20007
|
-
}], false);
|
|
20428
|
+
}], void 0, false);
|
|
20008
20429
|
this._scrollToFocusNodePosition(docDataModel.getUnitId(), cursor);
|
|
20009
20430
|
}
|
|
20010
20431
|
}
|
|
@@ -20455,8 +20876,8 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
20455
20876
|
return (parent === null || parent === void 0 ? void 0 : parent.page) === page && ((_parent$parent = parent.parent) === null || _parent$parent === void 0 || (_parent$parent = _parent$parent.columns) === null || _parent$parent === void 0 ? void 0 : _parent$parent.includes(parent)) === true;
|
|
20456
20877
|
}
|
|
20457
20878
|
_scrollToFocusNodePosition(unitId, offset) {
|
|
20458
|
-
var _this$
|
|
20459
|
-
const backScrollController = (_this$
|
|
20879
|
+
var _this$_renderManagerS;
|
|
20880
|
+
const backScrollController = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(DocBackScrollRenderController);
|
|
20460
20881
|
if (backScrollController == null) return;
|
|
20461
20882
|
backScrollController.scrollToRange({
|
|
20462
20883
|
startOffset: offset,
|
|
@@ -20464,9 +20885,6 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
20464
20885
|
collapsed: true
|
|
20465
20886
|
});
|
|
20466
20887
|
}
|
|
20467
|
-
_getDocObject() {
|
|
20468
|
-
return getDocObject(this._univerInstanceService, this._renderManagerService);
|
|
20469
|
-
}
|
|
20470
20888
|
};
|
|
20471
20889
|
DocMoveCursorController = __decorate([
|
|
20472
20890
|
__decorateParam(0, _univerjs_core.IUniverInstanceService),
|
|
@@ -20734,7 +21152,7 @@ let DocEditorBridgeController = class DocEditorBridgeController extends _univerj
|
|
|
20734
21152
|
disposableCollection.dispose();
|
|
20735
21153
|
if (!unit) return;
|
|
20736
21154
|
const unitId = unit.getUnitId();
|
|
20737
|
-
const render = this._renderManagerService.
|
|
21155
|
+
const render = this._renderManagerService.getRenderUnitById(unitId);
|
|
20738
21156
|
const canvasEle = render === null || render === void 0 ? void 0 : render.engine.getCanvas().getCanvasEle();
|
|
20739
21157
|
if (canvasEle == null) return;
|
|
20740
21158
|
const disposable = (0, rxjs.fromEvent)(canvasEle, "mousedown").subscribe((evt) => {
|
|
@@ -20753,8 +21171,8 @@ let DocEditorBridgeController = class DocEditorBridgeController extends _univerj
|
|
|
20753
21171
|
if (updateCommandList.includes(command.id)) {
|
|
20754
21172
|
const { unitId } = command.params;
|
|
20755
21173
|
if (this._editorService.isSheetEditor(unitId) || unitId !== this._context.unitId) return;
|
|
20756
|
-
const
|
|
20757
|
-
if (
|
|
21174
|
+
const editorRenderConfig = this._editorService.getEditorRenderConfig(unitId);
|
|
21175
|
+
if (editorRenderConfig && !editorRenderConfig.scrollBar) this._resize(unitId);
|
|
20758
21176
|
}
|
|
20759
21177
|
}));
|
|
20760
21178
|
}
|
|
@@ -21219,7 +21637,7 @@ let DocZoomRenderController = class DocZoomRenderController extends _univerjs_co
|
|
|
21219
21637
|
this._initCommandExecutedListener();
|
|
21220
21638
|
this._isSheetEditor = this._context.unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY;
|
|
21221
21639
|
const currentSheet = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
21222
|
-
const sheetRenderer = currentSheet && this._renderManagerService.
|
|
21640
|
+
const sheetRenderer = currentSheet && this._renderManagerService.getRenderUnitById(currentSheet.getUnitId());
|
|
21223
21641
|
this._initTimer = window.setTimeout(() => {
|
|
21224
21642
|
const zoomRatio = sheetRenderer && this._isSheetEditor ? sheetRenderer.scene.scaleX : getDocEffectiveZoomRatio(this._context.unit);
|
|
21225
21643
|
this.updateViewZoom(zoomRatio, true);
|
|
@@ -21385,7 +21803,6 @@ let DocsRenderService = class DocsRenderService extends _univerjs_core.RxDisposa
|
|
|
21385
21803
|
this._init();
|
|
21386
21804
|
}
|
|
21387
21805
|
_init() {
|
|
21388
|
-
this._renderManagerService.createRender$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((unitId) => this._createRenderWithId(unitId));
|
|
21389
21806
|
this._instanceSrv.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_DOC).forEach((documentModel) => {
|
|
21390
21807
|
var _this$_instanceSrv$ge;
|
|
21391
21808
|
return this._createRenderer(documentModel, (_this$_instanceSrv$ge = this._instanceSrv.getUnitCreateOptions(documentModel.getUnitId())) !== null && _this$_instanceSrv$ge !== void 0 ? _this$_instanceSrv$ge : void 0);
|
|
@@ -21400,7 +21817,7 @@ let DocsRenderService = class DocsRenderService extends _univerjs_core.RxDisposa
|
|
|
21400
21817
|
this._createRenderWithId(unitId, doc);
|
|
21401
21818
|
return;
|
|
21402
21819
|
}
|
|
21403
|
-
const renderer = this._renderManagerService.
|
|
21820
|
+
const renderer = this._renderManagerService.getRenderUnitById(unitId);
|
|
21404
21821
|
if (renderer) this._syncRendererCanvas(renderer, doc);
|
|
21405
21822
|
}
|
|
21406
21823
|
_createRenderWithId(unitId, doc) {
|
|
@@ -21662,13 +22079,14 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
21662
22079
|
DocParagraphSettingCommand,
|
|
21663
22080
|
InnerPasteCommand,
|
|
21664
22081
|
CutContentCommand,
|
|
21665
|
-
ReplaceContentCommand,
|
|
21666
22082
|
ReplaceSnapshotCommand,
|
|
21667
22083
|
CoverContentCommand,
|
|
21668
22084
|
SetDocZoomRatioCommand,
|
|
21669
22085
|
DocSelectAllCommand,
|
|
21670
22086
|
DocParagraphSettingPanelOperation,
|
|
21671
22087
|
DocSectionSettingPanelOperation,
|
|
22088
|
+
InsertDocumentColumnBreakOperation,
|
|
22089
|
+
InsertDocumentSectionBreakOperation,
|
|
21672
22090
|
MoveCursorOperation,
|
|
21673
22091
|
MoveSelectionOperation,
|
|
21674
22092
|
ReplaceTextRunsCommand,
|
|
@@ -21818,7 +22236,7 @@ _defineProperty(UniverDocsUIPlugin, "pluginName", "DOC_UI_PLUGIN");
|
|
|
21818
22236
|
_defineProperty(UniverDocsUIPlugin, "packageName", name);
|
|
21819
22237
|
_defineProperty(UniverDocsUIPlugin, "version", version);
|
|
21820
22238
|
UniverDocsUIPlugin = __decorate([
|
|
21821
|
-
(0, _univerjs_core.DependentOn)(
|
|
22239
|
+
(0, _univerjs_core.DependentOn)(_univerjs_docs.UniverDocsPlugin, _univerjs_engine_render.UniverRenderEnginePlugin),
|
|
21822
22240
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
21823
22241
|
__decorateParam(2, _univerjs_engine_render.IRenderManagerService),
|
|
21824
22242
|
__decorateParam(3, _univerjs_core.ICommandService),
|
|
@@ -21899,7 +22317,7 @@ function useEditor(opts) {
|
|
|
21899
22317
|
const editorService = (0, _univerjs_ui.useDependency)(IEditorService);
|
|
21900
22318
|
(0, react.useLayoutEffect)(() => {
|
|
21901
22319
|
if (container.current) {
|
|
21902
|
-
const initialDoc = typeof initialValue === "string" ?
|
|
22320
|
+
const initialDoc = typeof initialValue === "string" ? _univerjs_core.RichTextBuilder.create().insertText(initialValue).getData() : _univerjs_core.Tools.deepClone(initialValue);
|
|
21903
22321
|
const snapshot = {
|
|
21904
22322
|
body: {
|
|
21905
22323
|
dataStream: typeof initialValue === "string" ? `${initialValue}\r\n` : "\r\n",
|
|
@@ -21992,7 +22410,7 @@ const useEditorClickOutside = (editorId, containerRef, onClickOutside) => {
|
|
|
21992
22410
|
*/
|
|
21993
22411
|
function useIsFocusing(editorId) {
|
|
21994
22412
|
var _docSelectionRenderSe;
|
|
21995
|
-
const renderer = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService).
|
|
22413
|
+
const renderer = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(editorId);
|
|
21996
22414
|
const docSelectionRenderService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocSelectionRenderService);
|
|
21997
22415
|
const selections = (0, _univerjs_ui.useObservable)(docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.textSelectionInner$);
|
|
21998
22416
|
return Boolean(((_docSelectionRenderSe = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing) !== null && _docSelectionRenderSe !== void 0 ? _docSelectionRenderSe : false) && (selections === null || selections === void 0 ? void 0 : selections.textRanges.some((r) => r.collapsed)));
|
|
@@ -22006,7 +22424,8 @@ function useKeyboardEvent(isNeed, config, editor) {
|
|
|
22006
22424
|
const key = (0, react.useMemo)(() => (0, _univerjs_core.generateRandomId)(4), []);
|
|
22007
22425
|
(0, react.useEffect)(() => {
|
|
22008
22426
|
if (!editor || !isNeed || !config) return;
|
|
22009
|
-
const
|
|
22427
|
+
const editorId = editor.getEditorId();
|
|
22428
|
+
const operationId = `sheet.operation.editor-${editorId}-keyboard-${key}`;
|
|
22010
22429
|
const d = new _univerjs_core.DisposableCollection();
|
|
22011
22430
|
d.add(commandService.registerCommand({
|
|
22012
22431
|
id: operationId,
|
|
@@ -22020,6 +22439,8 @@ function useKeyboardEvent(isNeed, config, editor) {
|
|
|
22020
22439
|
return {
|
|
22021
22440
|
id: operationId,
|
|
22022
22441
|
binding: keyCode.metaKey ? keyCode.keyCode | keyCode.metaKey : keyCode.keyCode,
|
|
22442
|
+
eventPreconditions: keyCode.nativeTextEditorBehavior == null ? void 0 : (event) => event.target instanceof HTMLElement && event.target.id === `__editor_${editorId}`,
|
|
22443
|
+
nativeTextEditorBehavior: keyCode.nativeTextEditorBehavior,
|
|
22023
22444
|
preconditions: () => true,
|
|
22024
22445
|
priority: 901,
|
|
22025
22446
|
staticParameters: {
|
|
@@ -22295,7 +22716,7 @@ const RichTextEditor = (props) => {
|
|
|
22295
22716
|
autoFocus,
|
|
22296
22717
|
isSingle
|
|
22297
22718
|
});
|
|
22298
|
-
const renderer = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService).
|
|
22719
|
+
const renderer = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(editorId);
|
|
22299
22720
|
const selectionIsFocusing = useIsFocusing(editorId);
|
|
22300
22721
|
const docSelectionRenderService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocSelectionRenderService);
|
|
22301
22722
|
const editorFocused = (0, _univerjs_ui.useObservable)(editor ? () => {
|
|
@@ -22408,6 +22829,8 @@ exports.DOCS_COMPONENT_MAIN_LAYER_INDEX = DOCS_COMPONENT_MAIN_LAYER_INDEX;
|
|
|
22408
22829
|
exports.DOCS_UI_PLUGIN_CONFIG_KEY = DOCS_UI_PLUGIN_CONFIG_KEY;
|
|
22409
22830
|
exports.DOCS_VIEW_KEY = DOCS_VIEW_KEY;
|
|
22410
22831
|
exports.DOC_CONTENT_INSERT_MENU_ID = DOC_CONTENT_INSERT_MENU_ID;
|
|
22832
|
+
exports.DOC_CUSTOM_RANGE_CHROME_BACKGROUND_ALPHA = DOC_CUSTOM_RANGE_CHROME_BACKGROUND_ALPHA;
|
|
22833
|
+
exports.DOC_CUSTOM_RANGE_CHROME_RADIUS = DOC_CUSTOM_RANGE_CHROME_RADIUS;
|
|
22411
22834
|
exports.DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE;
|
|
22412
22835
|
exports.DOC_PARAGRAPH_T_ALIGN_MENU_ID = DOC_PARAGRAPH_T_ALIGN_MENU_ID;
|
|
22413
22836
|
exports.DOC_PARAGRAPH_T_COLORS_MENU_ID = DOC_PARAGRAPH_T_COLORS_MENU_ID;
|
|
@@ -22519,12 +22942,6 @@ Object.defineProperty(exports, 'DocsRenderService', {
|
|
|
22519
22942
|
}
|
|
22520
22943
|
});
|
|
22521
22944
|
exports.DocsUIMenuSchema = menuSchema;
|
|
22522
|
-
Object.defineProperty(exports, 'EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY', {
|
|
22523
|
-
enumerable: true,
|
|
22524
|
-
get: function () {
|
|
22525
|
-
return _univerjs_docs.EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY;
|
|
22526
|
-
}
|
|
22527
|
-
});
|
|
22528
22945
|
exports.EMPTY_PARAGRAPH_MENU_ID = EMPTY_PARAGRAPH_MENU_ID;
|
|
22529
22946
|
exports.Editor = Editor;
|
|
22530
22947
|
Object.defineProperty(exports, 'EditorService', {
|
|
@@ -22565,7 +22982,6 @@ exports.PastePluginUniver = UniverPastePlugin;
|
|
|
22565
22982
|
exports.PastePluginWord = WordPastePlugin;
|
|
22566
22983
|
exports.QuickListCommand = QuickListCommand;
|
|
22567
22984
|
exports.RectRange = RectRange;
|
|
22568
|
-
exports.ReplaceContentCommand = ReplaceContentCommand;
|
|
22569
22985
|
exports.ReplaceSelectionCommand = ReplaceSelectionCommand;
|
|
22570
22986
|
exports.ReplaceSnapshotCommand = ReplaceSnapshotCommand;
|
|
22571
22987
|
exports.ReplaceTextRunsCommand = ReplaceTextRunsCommand;
|
|
@@ -22611,40 +23027,11 @@ exports.collectDocsTableLikeEmbedChildUnitIds = collectDocsTableLikeEmbedChildUn
|
|
|
22611
23027
|
exports.convertBodyToHtml = convertBodyToHtml;
|
|
22612
23028
|
exports.convertPositionsToRectRanges = convertPositionsToRectRanges;
|
|
22613
23029
|
exports.createDefaultDocsTableLikeCustomBlockBleedViewport = createDefaultDocsTableLikeCustomBlockBleedViewport;
|
|
22614
|
-
Object.defineProperty(exports, 'createDocsCustomBlockInsertMutation', {
|
|
22615
|
-
enumerable: true,
|
|
22616
|
-
get: function () {
|
|
22617
|
-
return _univerjs_docs.createDocsCustomBlockInsertMutation;
|
|
22618
|
-
}
|
|
22619
|
-
});
|
|
22620
|
-
Object.defineProperty(exports, 'createDocsCustomBlockRemoveMutation', {
|
|
22621
|
-
enumerable: true,
|
|
22622
|
-
get: function () {
|
|
22623
|
-
return _univerjs_docs.createDocsCustomBlockRemoveMutation;
|
|
22624
|
-
}
|
|
22625
|
-
});
|
|
22626
23030
|
exports.createDocsCustomBlockSizeRefreshScheduler = createDocsCustomBlockSizeRefreshScheduler;
|
|
22627
23031
|
exports.createEditorUndoRedoKeyboardConfig = createEditorUndoRedoKeyboardConfig;
|
|
22628
|
-
Object.defineProperty(exports, 'createEmbedDocsCustomBlockData', {
|
|
22629
|
-
enumerable: true,
|
|
22630
|
-
get: function () {
|
|
22631
|
-
return _univerjs_docs.createEmbedDocsCustomBlockData;
|
|
22632
|
-
}
|
|
22633
|
-
});
|
|
22634
|
-
Object.defineProperty(exports, 'createInsertCustomBlockActions', {
|
|
22635
|
-
enumerable: true,
|
|
22636
|
-
get: function () {
|
|
22637
|
-
return _univerjs_docs.createInsertCustomBlockActions;
|
|
22638
|
-
}
|
|
22639
|
-
});
|
|
22640
|
-
Object.defineProperty(exports, 'createRemoveCustomBlockActions', {
|
|
22641
|
-
enumerable: true,
|
|
22642
|
-
get: function () {
|
|
22643
|
-
return _univerjs_docs.createRemoveCustomBlockActions;
|
|
22644
|
-
}
|
|
22645
|
-
});
|
|
22646
23032
|
exports.deleteCustomDecorationFactory = deleteCustomDecorationFactory;
|
|
22647
23033
|
exports.disableMenuWhenHeaderFooterEditing = disableMenuWhenHeaderFooterEditing;
|
|
23034
|
+
exports.drawDocCustomRangeChrome = drawDocCustomRangeChrome;
|
|
22648
23035
|
exports.executeEditorUndoRedoCommand = executeEditorUndoRedoCommand;
|
|
22649
23036
|
exports.genTableSource = genTableSource;
|
|
22650
23037
|
exports.generateParagraphs = _univerjs_docs.generateParagraphs;
|
|
@@ -22654,7 +23041,6 @@ exports.getCommandSkeleton = getCommandSkeleton;
|
|
|
22654
23041
|
exports.getCursorWhenDelete = getCursorWhenDelete;
|
|
22655
23042
|
exports.getCutActionsFromDocRanges = getCutActionsFromDocRanges;
|
|
22656
23043
|
exports.getDocBlockRangeMenuId = getDocBlockRangeMenuId;
|
|
22657
|
-
exports.getDocObject = getDocObject;
|
|
22658
23044
|
exports.getDocObjectById = getDocObjectById;
|
|
22659
23045
|
exports.getEmptyTableCell = getEmptyTableCell;
|
|
22660
23046
|
exports.getEmptyTableRow = getEmptyTableRow;
|
|
@@ -22664,28 +23050,18 @@ exports.getListParagraphContextMenuHit = getListParagraphContextMenuHit;
|
|
|
22664
23050
|
exports.getOneTextSelectionRange = getOneTextSelectionRange;
|
|
22665
23051
|
exports.getStyleInTextRange = getStyleInTextRange;
|
|
22666
23052
|
exports.getTableColumn = getTableColumn;
|
|
23053
|
+
exports.getTextRangeFromCharIndex = getTextRangeFromCharIndex;
|
|
22667
23054
|
exports.hasParagraphInTable = hasParagraphInTable;
|
|
22668
23055
|
exports.hideMenuWhenSelectionInBlockRange = hideMenuWhenSelectionInBlockRange;
|
|
22669
23056
|
exports.isInSameTableCell = isInSameTableCell;
|
|
22670
|
-
Object.defineProperty(exports, 'isSheetLikeDocsCustomBlockChildType', {
|
|
22671
|
-
enumerable: true,
|
|
22672
|
-
get: function () {
|
|
22673
|
-
return _univerjs_docs.isSheetLikeDocsCustomBlockChildType;
|
|
22674
|
-
}
|
|
22675
|
-
});
|
|
22676
23057
|
exports.isTextRangeInAnyBlockRange = isTextRangeInAnyBlockRange;
|
|
22677
23058
|
exports.isValidRectRange = isValidRectRange;
|
|
22678
23059
|
exports.neoGetDocObject = neoGetDocObject;
|
|
22679
23060
|
exports.normalizeDocFitToWidthOptions = normalizeDocFitToWidthOptions;
|
|
23061
|
+
exports.resolveDocCustomRangeChromeTheme = resolveDocCustomRangeChromeTheme;
|
|
22680
23062
|
exports.resolveDocFitBaseWidth = resolveDocFitBaseWidth;
|
|
22681
23063
|
exports.resolveDocViewScale = resolveDocViewScale;
|
|
22682
23064
|
exports.resolveDocsCustomBlockRenderViewport = resolveDocsCustomBlockRenderViewport;
|
|
22683
|
-
Object.defineProperty(exports, 'resolveDocsCustomBlockSize', {
|
|
22684
|
-
enumerable: true,
|
|
22685
|
-
get: function () {
|
|
22686
|
-
return _univerjs_docs.resolveDocsCustomBlockSize;
|
|
22687
|
-
}
|
|
22688
|
-
});
|
|
22689
23065
|
exports.resolveDocsTableLikeCustomBlockBleedViewport = resolveDocsTableLikeCustomBlockBleedViewport;
|
|
22690
23066
|
exports.resolveDocsTableLikeCustomBlockContentHeight = resolveDocsTableLikeCustomBlockContentHeight;
|
|
22691
23067
|
exports.resolveDocsTableLikeCustomBlockContentWidth = resolveDocsTableLikeCustomBlockContentWidth;
|