@univerjs/docs-ui 1.0.0-alpha.8 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -284,10 +284,7 @@ let DocAutoFormatService = class DocAutoFormatService extends Disposable {
284
284
  const matchList = this._matches.get(match.id);
285
285
  if (matchList) {
286
286
  matchList.push(match);
287
- matchList.sort((a, b) => {
288
- var _b$priority, _a$priority;
289
- return ((_b$priority = b.priority) !== null && _b$priority !== void 0 ? _b$priority : 0) - ((_a$priority = a.priority) !== null && _a$priority !== void 0 ? _a$priority : 0);
290
- });
287
+ matchList.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
291
288
  } else this._matches.set(match.id, [match]);
292
289
  return toDisposable(() => {
293
290
  const matchList = this._matches.get(match.id);
@@ -298,25 +295,24 @@ let DocAutoFormatService = class DocAutoFormatService extends Disposable {
298
295
  });
299
296
  }
300
297
  onAutoFormat(id, params) {
301
- var _this$_matches$get, _docRanges$find, _selection$segmentId;
302
- const autoFormats = (_this$_matches$get = this._matches.get(id)) !== null && _this$_matches$get !== void 0 ? _this$_matches$get : [];
298
+ const autoFormats = this._matches.get(id) ?? [];
303
299
  const unit = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
304
300
  const docRanges = this._textSelectionManagerService.getDocRanges();
305
- const selection = (_docRanges$find = docRanges.find((range) => range.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
306
- const documentDataModel = unit === null || unit === void 0 ? void 0 : unit.getSelfOrHeaderFooterModel((_selection$segmentId = selection === null || selection === void 0 ? void 0 : selection.segmentId) !== null && _selection$segmentId !== void 0 ? _selection$segmentId : "");
301
+ const selection = docRanges.find((range) => range.isActive) ?? docRanges[0];
302
+ const documentDataModel = unit === null || unit === void 0 ? void 0 : unit.getSelfOrHeaderFooterModel((selection === null || selection === void 0 ? void 0 : selection.segmentId) ?? "");
307
303
  if (unit && selection && documentDataModel) {
308
- var _documentDataModel$ge, _documentDataModel$ge2, _documentDataModel$ge3, _documentDataModel$ge4, _documentDataModel$ge5, _documentDataModel$ge6, _matched$getMutations;
304
+ var _documentDataModel$ge, _documentDataModel$ge2, _documentDataModel$ge3;
309
305
  const context = {
310
306
  unit: documentDataModel,
311
307
  selection,
312
308
  isBody: !selection.segmentId,
313
- paragraphs: BuildTextUtils.range.getParagraphsInRange(selection, (_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.paragraphs) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : [], (_documentDataModel$ge3 = (_documentDataModel$ge4 = documentDataModel.getBody()) === null || _documentDataModel$ge4 === void 0 ? void 0 : _documentDataModel$ge4.dataStream) !== null && _documentDataModel$ge3 !== void 0 ? _documentDataModel$ge3 : ""),
314
- customRanges: BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (_documentDataModel$ge5 = (_documentDataModel$ge6 = documentDataModel.getBody()) === null || _documentDataModel$ge6 === void 0 ? void 0 : _documentDataModel$ge6.customRanges) !== null && _documentDataModel$ge5 !== void 0 ? _documentDataModel$ge5 : []),
309
+ paragraphs: BuildTextUtils.range.getParagraphsInRange(selection, ((_documentDataModel$ge = documentDataModel.getBody()) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.paragraphs) ?? [], ((_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.dataStream) ?? ""),
310
+ customRanges: BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, ((_documentDataModel$ge3 = documentDataModel.getBody()) === null || _documentDataModel$ge3 === void 0 ? void 0 : _documentDataModel$ge3.customRanges) ?? []),
315
311
  commandId: id,
316
312
  commandParams: params
317
313
  };
318
314
  const matched = autoFormats.find((i) => i.match(context));
319
- return (_matched$getMutations = matched === null || matched === void 0 ? void 0 : matched.getMutations(context)) !== null && _matched$getMutations !== void 0 ? _matched$getMutations : [];
315
+ return (matched === null || matched === void 0 ? void 0 : matched.getMutations(context)) ?? [];
320
316
  }
321
317
  return [];
322
318
  }
@@ -419,12 +415,12 @@ const BreakLineCommand = {
419
415
  id: "doc.command.break-line",
420
416
  type: CommandType.COMMAND,
421
417
  handler: (accessor, params) => {
422
- var _params$textRange, _docDataModel$getSelf, _originBody$paragraph, _prevParagraph$bullet, _prevParagraph$paragr;
418
+ var _docDataModel$getSelf, _prevParagraph$bullet, _prevParagraph$paragr;
423
419
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
424
420
  const univerInstanceService = accessor.get(IUniverInstanceService);
425
421
  const commandService = accessor.get(ICommandService);
426
422
  const docMenuStyleService = accessor.get(DocMenuStyleService);
427
- const activeTextRange = (_params$textRange = params === null || params === void 0 ? void 0 : params.textRange) !== null && _params$textRange !== void 0 ? _params$textRange : docSelectionManagerService.getActiveTextRange();
423
+ const activeTextRange = (params === null || params === void 0 ? void 0 : params.textRange) ?? docSelectionManagerService.getActiveTextRange();
428
424
  const rectRanges = docSelectionManagerService.getRectRanges();
429
425
  if (activeTextRange == null) return false;
430
426
  if (rectRanges && rectRanges.length) {
@@ -435,15 +431,16 @@ const BreakLineCommand = {
435
431
  }]);
436
432
  return true;
437
433
  }
438
- const { horizontalLine, insertionMode = "split-paragraph" } = params !== null && params !== void 0 ? params : {};
434
+ const { horizontalLine, insertionMode = "split-paragraph" } = params ?? {};
439
435
  const { segmentId } = activeTextRange;
440
436
  const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
441
- const originBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId !== null && segmentId !== void 0 ? segmentId : "")) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
437
+ const originBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId ?? "")) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
442
438
  if (docDataModel == null || originBody == null) return false;
443
439
  const unitId = docDataModel.getUnitId();
444
440
  const { startOffset, endOffset } = activeTextRange;
445
- const paragraphs = (_originBody$paragraph = originBody.paragraphs) !== null && _originBody$paragraph !== void 0 ? _originBody$paragraph : [];
446
- const insertsAtStructuralGap = insertionMode === "insert-gap" || isTopLevelStructuralGap(originBody.dataStream, startOffset);
441
+ const paragraphs = originBody.paragraphs ?? [];
442
+ const isBareStructuralGap = isTopLevelStructuralGap(originBody.dataStream, startOffset) && originBody.dataStream[startOffset] !== DataStreamTreeTokenType.PARAGRAPH;
443
+ const insertsAtStructuralGap = insertionMode === "insert-gap" || isBareStructuralGap;
447
444
  const prevParagraph = insertsAtStructuralGap ? void 0 : paragraphs.find((p) => p.startIndex >= startOffset);
448
445
  if (!prevParagraph && !insertsAtStructuralGap) return false;
449
446
  const isAtParagraphEnd = startOffset === (prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.startIndex);
@@ -1128,7 +1125,6 @@ const InnerPasteCommand = {
1128
1125
  if (hasTable && hasRangeInTable(selections)) return false;
1129
1126
  if (selections.length && (rectRanges === null || rectRanges === void 0 ? void 0 : rectRanges.length)) return false;
1130
1127
  for (let i = 0; i < selections.length; i++) {
1131
- var _originBody$customRan, _originBody$customDec;
1132
1128
  const selection = selections[i];
1133
1129
  const { startOffset, endOffset, collapsed } = selection;
1134
1130
  const len = startOffset - memoryCursor.cursor;
@@ -1158,8 +1154,8 @@ const InnerPasteCommand = {
1158
1154
  rawActions.push(action);
1159
1155
  }
1160
1156
  if (hasCustomBlock && drawings) {
1161
- var _docDataModel$getSnap, _docDataModel$getSnap2;
1162
- const drawingLen = (_docDataModel$getSnap = (_docDataModel$getSnap2 = docDataModel.getSnapshot().drawingsOrder) === null || _docDataModel$getSnap2 === void 0 ? void 0 : _docDataModel$getSnap2.length) !== null && _docDataModel$getSnap !== void 0 ? _docDataModel$getSnap : 0;
1157
+ var _docDataModel$getSnap;
1158
+ const drawingLen = ((_docDataModel$getSnap = docDataModel.getSnapshot().drawingsOrder) === null || _docDataModel$getSnap === void 0 ? void 0 : _docDataModel$getSnap.length) ?? 0;
1163
1159
  for (const block of cloneBody.customBlocks) {
1164
1160
  const { blockId } = block;
1165
1161
  const drawingId = generateRandomId(6);
@@ -1198,8 +1194,8 @@ const InnerPasteCommand = {
1198
1194
  resourceMutationGroups.push(mutationInfos);
1199
1195
  }
1200
1196
  }
1201
- const customRange = getCustomRangeAtPosition((_originBody$customRan = originBody.customRanges) !== null && _originBody$customRan !== void 0 ? _originBody$customRan : [], endOffset, UNITS.includes(unitId));
1202
- const customDecorations = getCustomDecorationAtPosition((_originBody$customDec = originBody.customDecorations) !== null && _originBody$customDec !== void 0 ? _originBody$customDec : [], endOffset);
1197
+ const customRange = getCustomRangeAtPosition(originBody.customRanges ?? [], endOffset, UNITS.includes(unitId));
1198
+ const customDecorations = getCustomDecorationAtPosition(originBody.customDecorations ?? [], endOffset);
1203
1199
  if (customRange) cloneBody.customRanges = [{
1204
1200
  ...customRange,
1205
1201
  startIndex: 0,
@@ -1292,7 +1288,7 @@ function adjustSelectionByTable(selection, tables) {
1292
1288
  };
1293
1289
  }
1294
1290
  function getCutActionsFromTextRanges(selections, docDataModel, segmentId) {
1295
- var _docDataModel$getSelf2, _docDataModel$getDraw, _docDataModel$getDraw2;
1291
+ var _docDataModel$getSelf2;
1296
1292
  const originBody = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
1297
1293
  const textX = new TextX();
1298
1294
  const jsonX = JSONX.getInstance();
@@ -1316,8 +1312,8 @@ function getCutActionsFromTextRanges(selections, docDataModel, segmentId) {
1316
1312
  const path = getRichTextEditPath(docDataModel, segmentId);
1317
1313
  rawActions.push(jsonX.editOp(textX.serialize(), path));
1318
1314
  const removedCustomBlockIds = getCustomBlockIdsInSelections(originBody, selections);
1319
- const drawings = (_docDataModel$getDraw = docDataModel.getDrawings()) !== null && _docDataModel$getDraw !== void 0 ? _docDataModel$getDraw : {};
1320
- const drawingOrder = (_docDataModel$getDraw2 = docDataModel.getDrawingsOrder()) !== null && _docDataModel$getDraw2 !== void 0 ? _docDataModel$getDraw2 : [];
1315
+ const drawings = docDataModel.getDrawings() ?? {};
1316
+ const drawingOrder = docDataModel.getDrawingsOrder() ?? [];
1321
1317
  const sortedRemovedCustomBlockIds = removedCustomBlockIds.sort((a, b) => {
1322
1318
  if (drawingOrder.indexOf(a) > drawingOrder.indexOf(b)) return -1;
1323
1319
  else if (drawingOrder.indexOf(a) < drawingOrder.indexOf(b)) return 1;
@@ -1462,12 +1458,12 @@ const CutContentCommand = {
1462
1458
  //#endregion
1463
1459
  //#region src/commands/commands/util.ts
1464
1460
  function getCurrentParagraph(accessor) {
1465
- var _doc$getBody$paragrap, _doc$getBody, _doc$getBody$dataStre, _doc$getBody2;
1461
+ var _doc$getBody, _doc$getBody2;
1466
1462
  const instanceService = accessor.get(IUniverInstanceService);
1467
1463
  const range = accessor.get(DocSelectionManagerService).getActiveTextRange();
1468
1464
  const doc = instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
1469
1465
  if (!range || !range.collapsed || !doc || range.segmentId) return false;
1470
- return BuildTextUtils.range.getParagraphsInRange(range, (_doc$getBody$paragrap = (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.paragraphs) !== null && _doc$getBody$paragrap !== void 0 ? _doc$getBody$paragrap : [], (_doc$getBody$dataStre = (_doc$getBody2 = doc.getBody()) === null || _doc$getBody2 === void 0 ? void 0 : _doc$getBody2.dataStream) !== null && _doc$getBody$dataStre !== void 0 ? _doc$getBody$dataStre : "")[0];
1466
+ return BuildTextUtils.range.getParagraphsInRange(range, ((_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.paragraphs) ?? [], ((_doc$getBody2 = doc.getBody()) === null || _doc$getBody2 === void 0 ? void 0 : _doc$getBody2.dataStream) ?? "")[0];
1471
1467
  }
1472
1468
 
1473
1469
  //#endregion
@@ -1476,7 +1472,6 @@ const DeleteCustomBlockCommand = {
1476
1472
  id: "doc.command.delete-custom-block",
1477
1473
  type: CommandType.COMMAND,
1478
1474
  handler: async (accessor, params) => {
1479
- var _documentDataModel$ge;
1480
1475
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
1481
1476
  const univerInstanceService = accessor.get(IUniverInstanceService);
1482
1477
  const commandService = accessor.get(ICommandService);
@@ -1513,7 +1508,7 @@ const DeleteCustomBlockCommand = {
1513
1508
  });
1514
1509
  const path = getRichTextEditPath(documentDataModel, segmentId);
1515
1510
  rawActions.push(jsonX.editOp(textX.serialize(), path));
1516
- const drawing = ((_documentDataModel$ge = documentDataModel.getDrawings()) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : {})[drawingId];
1511
+ const drawing = (documentDataModel.getDrawings() ?? {})[drawingId];
1517
1512
  const drawingIndex = documentDataModel.getDrawingsOrder().indexOf(drawingId);
1518
1513
  const removeDrawingAction = jsonX.removeOp(["drawings", drawingId], drawing);
1519
1514
  const removeDrawingOrderAction = jsonX.removeOp(["drawingsOrder", drawingIndex], drawingId);
@@ -1697,11 +1692,11 @@ function getCursorWhenDelete(textRanges, rectRanges) {
1697
1692
  return cursor;
1698
1693
  }
1699
1694
  function isDeleteOffsetInsideBlockRange(body, offset) {
1700
- var _body$blockRanges$som, _body$blockRanges;
1701
- return (_body$blockRanges$som = (_body$blockRanges = body.blockRanges) === null || _body$blockRanges === void 0 ? void 0 : _body$blockRanges.some((blockRange) => {
1695
+ var _body$blockRanges;
1696
+ return ((_body$blockRanges = body.blockRanges) === null || _body$blockRanges === void 0 ? void 0 : _body$blockRanges.some((blockRange) => {
1702
1697
  const interval = getBlockRangeInterval(blockRange);
1703
1698
  return interval.startOffset < offset && offset < interval.endOffset - 1;
1704
- })) !== null && _body$blockRanges$som !== void 0 ? _body$blockRanges$som : false;
1699
+ })) ?? false;
1705
1700
  }
1706
1701
  const DeleteLeftCommand = {
1707
1702
  id: "doc.command.delete-left",
@@ -1742,7 +1737,7 @@ const DeleteLeftCommand = {
1742
1737
  const { startOffset, collapsed } = actualRange;
1743
1738
  if (collapsed) {
1744
1739
  const emptyCenteredParagraph = getEmptyCenteredParagraphAtOffset(body, startOffset);
1745
- if (emptyCenteredParagraph != null) return resetEmptyCenteredParagraphAlignment(commandService, docDataModel, segmentId !== null && segmentId !== void 0 ? segmentId : "", emptyCenteredParagraph, style);
1740
+ if (emptyCenteredParagraph != null) return resetEmptyCenteredParagraphAlignment(commandService, docDataModel, segmentId ?? "", emptyCenteredParagraph, style);
1746
1741
  }
1747
1742
  const curGlyph = skeleton.findNodeByCharIndex(startOffset, segmentId, segmentPage);
1748
1743
  const isBullet = hasListGlyph(curGlyph);
@@ -1808,8 +1803,8 @@ const DeleteLeftCommand = {
1808
1803
  range: actualRange
1809
1804
  });
1810
1805
  } else if (preGlyph.streamType === "\b") {
1811
- var _docDataModel$getSnap, _preGlyph$drawingId, _docDataModel$getBody;
1812
- const drawing = (_docDataModel$getSnap = docDataModel.getSnapshot().drawings) === null || _docDataModel$getSnap === void 0 ? void 0 : _docDataModel$getSnap[(_preGlyph$drawingId = preGlyph.drawingId) !== null && _preGlyph$drawingId !== void 0 ? _preGlyph$drawingId : ""];
1806
+ var _docDataModel$getSnap, _docDataModel$getBody;
1807
+ const drawing = (_docDataModel$getSnap = docDataModel.getSnapshot().drawings) === null || _docDataModel$getSnap === void 0 ? void 0 : _docDataModel$getSnap[preGlyph.drawingId ?? ""];
1813
1808
  if (drawing == null) return true;
1814
1809
  const customBlock = (_docDataModel$getBody = docDataModel.getBody()) === null || _docDataModel$getBody === void 0 || (_docDataModel$getBody = _docDataModel$getBody.customBlocks) === null || _docDataModel$getBody === void 0 ? void 0 : _docDataModel$getBody.find((block) => block.blockId === preGlyph.drawingId);
1815
1810
  if (drawing.layoutType === PositionedObjectLayoutType.INLINE || (customBlock === null || customBlock === void 0 ? void 0 : customBlock.blockType) === BlockType.CUSTOM) {
@@ -1894,7 +1889,7 @@ const DeleteRightCommand = {
1894
1889
  const { startOffset, endOffset, collapsed } = actualRange;
1895
1890
  if (collapsed) {
1896
1891
  const emptyCenteredParagraph = getEmptyCenteredParagraphAtOffset(body, startOffset);
1897
- if (emptyCenteredParagraph != null) return resetEmptyCenteredParagraphAlignment(commandService, docDataModel, segmentId !== null && segmentId !== void 0 ? segmentId : "", emptyCenteredParagraph, style);
1892
+ if (emptyCenteredParagraph != null) return resetEmptyCenteredParagraphAlignment(commandService, docDataModel, segmentId ?? "", emptyCenteredParagraph, style);
1898
1893
  }
1899
1894
  if (startOffset === body.dataStream.length - 2 && collapsed) return true;
1900
1895
  let result = false;
@@ -1907,8 +1902,8 @@ const DeleteRightCommand = {
1907
1902
  range: activeRange
1908
1903
  });
1909
1904
  else if (needDeleteGlyph.streamType === "\b") {
1910
- var _docDataModel$getSnap2, _needDeleteGlyph$draw;
1911
- const drawing = (_docDataModel$getSnap2 = docDataModel.getSnapshot().drawings) === null || _docDataModel$getSnap2 === void 0 ? void 0 : _docDataModel$getSnap2[(_needDeleteGlyph$draw = needDeleteGlyph.drawingId) !== null && _needDeleteGlyph$draw !== void 0 ? _needDeleteGlyph$draw : ""];
1905
+ var _docDataModel$getSnap2;
1906
+ const drawing = (_docDataModel$getSnap2 = docDataModel.getSnapshot().drawings) === null || _docDataModel$getSnap2 === void 0 ? void 0 : _docDataModel$getSnap2[needDeleteGlyph.drawingId ?? ""];
1912
1907
  if (drawing == null) return true;
1913
1908
  if (drawing.layoutType === PositionedObjectLayoutType.INLINE) {
1914
1909
  const unitId = docDataModel.getUnitId();
@@ -1971,8 +1966,7 @@ function getTextRangesWhenDelete(activeRange, ranges) {
1971
1966
  }];
1972
1967
  }
1973
1968
  function getEmptyCenteredParagraphAtOffset(body, offset) {
1974
- var _body$paragraphs2;
1975
- const paragraphs = (_body$paragraphs2 = body.paragraphs) !== null && _body$paragraphs2 !== void 0 ? _body$paragraphs2 : [];
1969
+ const paragraphs = body.paragraphs ?? [];
1976
1970
  for (let i = 0; i < paragraphs.length; i++) {
1977
1971
  var _paragraph$paragraphS2;
1978
1972
  const paragraph = paragraphs[i];
@@ -2016,12 +2010,12 @@ const DeleteCurrentParagraphCommand = {
2016
2010
  priority: 0,
2017
2011
  type: CommandType.COMMAND,
2018
2012
  handler: async (accessor) => {
2019
- var _docDataModel$getBody2, _docDataModel$getBody3;
2013
+ var _docDataModel$getBody2;
2020
2014
  const univerInstanceService = accessor.get(IUniverInstanceService);
2021
2015
  const commandService = accessor.get(ICommandService);
2022
2016
  const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
2023
2017
  if (!docDataModel) return false;
2024
- const dataStream = (_docDataModel$getBody2 = (_docDataModel$getBody3 = docDataModel.getBody()) === null || _docDataModel$getBody3 === void 0 ? void 0 : _docDataModel$getBody3.dataStream) !== null && _docDataModel$getBody2 !== void 0 ? _docDataModel$getBody2 : "";
2018
+ const dataStream = ((_docDataModel$getBody2 = docDataModel.getBody()) === null || _docDataModel$getBody2 === void 0 ? void 0 : _docDataModel$getBody2.dataStream) ?? "";
2025
2019
  const paragraph = getCurrentParagraph(accessor);
2026
2020
  if (!paragraph) return false;
2027
2021
  const actions = BuildTextUtils.selection.delete([{
@@ -2196,9 +2190,9 @@ var HtmlToUDMService = class HtmlToUDMService {
2196
2190
  return createSectionId(new Set((_body$sectionBreaks = body.sectionBreaks) === null || _body$sectionBreaks === void 0 ? void 0 : _body$sectionBreaks.map((sectionBreak) => sectionBreak.sectionId)));
2197
2191
  }
2198
2192
  convert(html, metaConfig = {}) {
2199
- var _pastePlugin$preproce, _pastePlugin$preproce2, _metaConfig$unitId;
2193
+ var _pastePlugin$preproce;
2200
2194
  const pastePlugin = HtmlToUDMService._pluginList.find((plugin) => plugin.checkPasteType(html));
2201
- const dom = parseToDom((_pastePlugin$preproce = pastePlugin === null || pastePlugin === void 0 || (_pastePlugin$preproce2 = pastePlugin.preprocessHtml) === null || _pastePlugin$preproce2 === void 0 ? void 0 : _pastePlugin$preproce2.call(pastePlugin, html)) !== null && _pastePlugin$preproce !== void 0 ? _pastePlugin$preproce : html);
2195
+ const dom = parseToDom((pastePlugin === null || pastePlugin === void 0 || (_pastePlugin$preproce = pastePlugin.preprocessHtml) === null || _pastePlugin$preproce === void 0 ? void 0 : _pastePlugin$preproce.call(pastePlugin, html)) ?? html);
2202
2196
  const docData = {
2203
2197
  body: {
2204
2198
  dataStream: "",
@@ -2209,7 +2203,7 @@ var HtmlToUDMService = class HtmlToUDMService {
2209
2203
  customBlocks: []
2210
2204
  },
2211
2205
  tableSource: {},
2212
- id: (_metaConfig$unitId = metaConfig === null || metaConfig === void 0 ? void 0 : metaConfig.unitId) !== null && _metaConfig$unitId !== void 0 ? _metaConfig$unitId : ""
2206
+ id: (metaConfig === null || metaConfig === void 0 ? void 0 : metaConfig.unitId) ?? ""
2213
2207
  };
2214
2208
  if (pastePlugin) {
2215
2209
  this._styleRules = [...pastePlugin.stylesRules];
@@ -2239,16 +2233,15 @@ var HtmlToUDMService = class HtmlToUDMService {
2239
2233
  ts: style
2240
2234
  });
2241
2235
  } else if (node.nodeName === "IMG") {
2242
- var _element$dataset$imag;
2243
2236
  const element = node;
2244
- const imageSourceType = (_element$dataset$imag = element.dataset.imageSourceType) !== null && _element$dataset$imag !== void 0 ? _element$dataset$imag : element.src ? inferImageSourceType(element.src) : void 0;
2237
+ const imageSourceType = element.dataset.imageSourceType ?? (element.src ? inferImageSourceType(element.src) : void 0);
2245
2238
  const source = imageSourceType === ImageSourceType.UUID ? element.dataset.source : element.src;
2246
2239
  if (source && imageSourceType) {
2247
- var _readImageSize, _readImageSize2, _readCssSize, _readCssSize2, _doc$body;
2248
- const width = (_readImageSize = readImageSize(element, "width")) !== null && _readImageSize !== void 0 ? _readImageSize : 100;
2249
- const height = (_readImageSize2 = readImageSize(element, "height")) !== null && _readImageSize2 !== void 0 ? _readImageSize2 : 100;
2250
- const docTransformWidth = (_readCssSize = readCssSize(element.dataset.docTransformWidth || null, null, "width")) !== null && _readCssSize !== void 0 ? _readCssSize : width;
2251
- const docTransformHeight = (_readCssSize2 = readCssSize(element.dataset.docTransformHeight || null, null, "height")) !== null && _readCssSize2 !== void 0 ? _readCssSize2 : height;
2240
+ var _doc$body;
2241
+ const width = readImageSize(element, "width") ?? 100;
2242
+ const height = readImageSize(element, "height") ?? 100;
2243
+ const docTransformWidth = readCssSize(element.dataset.docTransformWidth || null, null, "width") ?? width;
2244
+ const docTransformHeight = readCssSize(element.dataset.docTransformHeight || null, null, "height") ?? height;
2252
2245
  const id = generateRandomId(6);
2253
2246
  (_doc$body = doc.body) === null || _doc$body === void 0 || (_doc$body = _doc$body.customBlocks) === null || _doc$body === void 0 || _doc$body.push({
2254
2247
  startIndex: body.dataStream.length,
@@ -2306,14 +2299,13 @@ var HtmlToUDMService = class HtmlToUDMService {
2306
2299
  }
2307
2300
  }
2308
2301
  _processCodeBlock(node, doc) {
2309
- var _node$textContent, _body$blockRanges;
2310
2302
  if (node.tagName.toUpperCase() !== "PRE") return false;
2311
2303
  const body = doc.body;
2312
2304
  const startIndex = body.dataStream.length;
2313
- const text = (_node$textContent = node.textContent) !== null && _node$textContent !== void 0 ? _node$textContent : "";
2305
+ const text = node.textContent ?? "";
2314
2306
  body.dataStream += text;
2315
2307
  this._appendParagraph(doc, node);
2316
- (_body$blockRanges = body.blockRanges) !== null && _body$blockRanges !== void 0 || (body.blockRanges = []);
2308
+ body.blockRanges ??= [];
2317
2309
  body.blockRanges.push({
2318
2310
  blockId: generateRandomId(6),
2319
2311
  blockType: DocumentBlockRangeType.CODE,
@@ -2327,11 +2319,10 @@ var HtmlToUDMService = class HtmlToUDMService {
2327
2319
  return doc.body.dataStream.length;
2328
2320
  }
2329
2321
  _processAfterStructuredBlock(node, doc, startIndex) {
2330
- var _body$blockRanges2;
2331
2322
  const blockType = getStructuredBlockType(node);
2332
2323
  const body = doc.body;
2333
2324
  if (!blockType || startIndex == null || body.dataStream.length <= startIndex) return;
2334
- (_body$blockRanges2 = body.blockRanges) !== null && _body$blockRanges2 !== void 0 || (body.blockRanges = []);
2325
+ body.blockRanges ??= [];
2335
2326
  body.blockRanges.push({
2336
2327
  blockId: generateRandomId(6),
2337
2328
  blockType,
@@ -2364,10 +2355,9 @@ var HtmlToUDMService = class HtmlToUDMService {
2364
2355
  this._appendParagraph(doc, node);
2365
2356
  }
2366
2357
  _appendParagraph(doc, node) {
2367
- var _body$paragraphs2, _this$_listStack;
2368
2358
  const body = doc.body;
2369
2359
  if (body.dataStream[this._lastParagraphIndex] === "\r" && this._lastParagraphIndex === body.dataStream.length - 1) return;
2370
- (_body$paragraphs2 = body.paragraphs) !== null && _body$paragraphs2 !== void 0 || (body.paragraphs = []);
2360
+ body.paragraphs ??= [];
2371
2361
  const paragraph = {
2372
2362
  startIndex: body.dataStream.length,
2373
2363
  paragraphId: this._createParagraphId(body)
@@ -2378,7 +2368,7 @@ var HtmlToUDMService = class HtmlToUDMService {
2378
2368
  headingId: generateRandomId(6),
2379
2369
  namedStyleType: heading
2380
2370
  };
2381
- const listContext = (_this$_listStack = this._listStack[this._listStack.length - 1]) !== null && _this$_listStack !== void 0 ? _this$_listStack : extractWordListInfo(node);
2371
+ const listContext = this._listStack[this._listStack.length - 1] ?? extractWordListInfo(node);
2382
2372
  if (listContext) {
2383
2373
  paragraph.bullet = {
2384
2374
  listId: listContext.listId,
@@ -2395,7 +2385,7 @@ var HtmlToUDMService = class HtmlToUDMService {
2395
2385
  var _doc$body2;
2396
2386
  const htmlListContext = this._listStack[this._listStack.length - 1];
2397
2387
  const wordListContext = extractWordListInfo(node);
2398
- const listContext = htmlListContext !== null && htmlListContext !== void 0 ? htmlListContext : wordListContext;
2388
+ const listContext = htmlListContext ?? wordListContext;
2399
2389
  const paragraph = (_doc$body2 = doc.body) === null || _doc$body2 === void 0 || (_doc$body2 = _doc$body2.paragraphs) === null || _doc$body2 === void 0 ? void 0 : _doc$body2[doc.body.paragraphs.length - 1];
2400
2390
  if (!listContext || !paragraph) return;
2401
2391
  paragraph.bullet = {
@@ -2406,20 +2396,18 @@ var HtmlToUDMService = class HtmlToUDMService {
2406
2396
  if (wordListContext) paragraph.startIndex -= stripListMarkerFromCurrentParagraph(doc.body);
2407
2397
  }
2408
2398
  _processHtmlTable(node, doc) {
2409
- var _doc$tableSource, _body$tables, _body$sectionBreaks2;
2410
2399
  const body = doc.body;
2411
2400
  if (body.dataStream[body.dataStream.length - 1] !== "\r") {
2412
- var _body$paragraphs3;
2413
2401
  body.dataStream += "\r";
2414
- (_body$paragraphs3 = body.paragraphs) !== null && _body$paragraphs3 !== void 0 || (body.paragraphs = []);
2402
+ body.paragraphs ??= [];
2415
2403
  body.paragraphs.push({
2416
2404
  startIndex: body.dataStream.length - 1,
2417
2405
  paragraphId: this._createParagraphId(body)
2418
2406
  });
2419
2407
  }
2420
- (_doc$tableSource = doc.tableSource) !== null && _doc$tableSource !== void 0 || (doc.tableSource = {});
2421
- (_body$tables = body.tables) !== null && _body$tables !== void 0 || (body.tables = []);
2422
- (_body$sectionBreaks2 = body.sectionBreaks) !== null && _body$sectionBreaks2 !== void 0 || (body.sectionBreaks = []);
2408
+ doc.tableSource ??= {};
2409
+ body.tables ??= [];
2410
+ body.sectionBreaks ??= [];
2423
2411
  const rows = collectHtmlTableRows(node);
2424
2412
  const grid = buildHtmlTableGrid(rows);
2425
2413
  const columnCount = Math.max(1, ...grid.map((row) => row.length));
@@ -2430,7 +2418,7 @@ var HtmlToUDMService = class HtmlToUDMService {
2430
2418
  table.tableColumns = columnWidths.map((width) => getTableColumn(width));
2431
2419
  table.size = {
2432
2420
  type: TableSizeType.SPECIFIED,
2433
- width: { v: tableWidth !== null && tableWidth !== void 0 ? tableWidth : table.tableColumns.reduce((sum, column) => sum + column.size.width.v, 0) }
2421
+ width: { v: tableWidth ?? table.tableColumns.reduce((sum, column) => sum + column.size.width.v, 0) }
2434
2422
  };
2435
2423
  const startIndex = body.dataStream.length;
2436
2424
  body.dataStream += DataStreamTreeTokenType.TABLE_START;
@@ -2445,8 +2433,7 @@ var HtmlToUDMService = class HtmlToUDMService {
2445
2433
  table.tableRows.push(tableRow);
2446
2434
  body.dataStream += DataStreamTreeTokenType.TABLE_ROW_START;
2447
2435
  for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
2448
- var _row$columnIndex;
2449
- const parsedCell = (_row$columnIndex = row[columnIndex]) !== null && _row$columnIndex !== void 0 ? _row$columnIndex : {
2436
+ const parsedCell = row[columnIndex] ?? {
2450
2437
  element: null,
2451
2438
  rowSpan: 1,
2452
2439
  colSpan: 1,
@@ -2471,15 +2458,11 @@ var HtmlToUDMService = class HtmlToUDMService {
2471
2458
  });
2472
2459
  }
2473
2460
  _appendHtmlTableCell(cell, doc) {
2474
- var _body$sectionBreaks3;
2475
2461
  const body = doc.body;
2476
2462
  body.dataStream += DataStreamTreeTokenType.TABLE_CELL_START;
2477
2463
  if (cell.element && !cell.covered) this._process(cell.element, cell.element.childNodes, doc);
2478
- if (body.dataStream[body.dataStream.length - 1] !== "\r") {
2479
- var _cell$element;
2480
- this._appendParagraph(doc, (_cell$element = cell.element) !== null && _cell$element !== void 0 ? _cell$element : document.createElement("td"));
2481
- }
2482
- (_body$sectionBreaks3 = body.sectionBreaks) !== null && _body$sectionBreaks3 !== void 0 || (body.sectionBreaks = []);
2464
+ if (body.dataStream[body.dataStream.length - 1] !== "\r") this._appendParagraph(doc, cell.element ?? document.createElement("td"));
2465
+ body.sectionBreaks ??= [];
2483
2466
  body.sectionBreaks.push({
2484
2467
  sectionId: this._createSectionId(body),
2485
2468
  startIndex: body.dataStream.length
@@ -2492,10 +2475,10 @@ var HtmlToUDMService = class HtmlToUDMService {
2492
2475
  switch (tagName) {
2493
2476
  case "TABLE": {
2494
2477
  if (body.dataStream[body.dataStream.length - 1] !== "\r") {
2495
- var _body$paragraphs4;
2478
+ var _body$paragraphs2;
2496
2479
  body.dataStream += "\r";
2497
2480
  if (body.paragraphs == null) body.paragraphs = [];
2498
- (_body$paragraphs4 = body.paragraphs) === null || _body$paragraphs4 === void 0 || _body$paragraphs4.push({
2481
+ (_body$paragraphs2 = body.paragraphs) === null || _body$paragraphs2 === void 0 || _body$paragraphs2.push({
2499
2482
  startIndex: body.dataStream.length - 1,
2500
2483
  paragraphId: this._createParagraphId(body)
2501
2484
  });
@@ -2549,16 +2532,16 @@ var HtmlToUDMService = class HtmlToUDMService {
2549
2532
  body.dataStream += DataStreamTreeTokenType.TABLE_ROW_END;
2550
2533
  break;
2551
2534
  case "TD":
2552
- var _body$sectionBreaks4;
2535
+ var _body$sectionBreaks2;
2553
2536
  if (body.dataStream[body.dataStream.length - 1] !== "\r") {
2554
- var _body$paragraphs5;
2555
- (_body$paragraphs5 = body.paragraphs) === null || _body$paragraphs5 === void 0 || _body$paragraphs5.push({
2537
+ var _body$paragraphs3;
2538
+ (_body$paragraphs3 = body.paragraphs) === null || _body$paragraphs3 === void 0 || _body$paragraphs3.push({
2556
2539
  startIndex: body.dataStream.length,
2557
2540
  paragraphId: this._createParagraphId(body)
2558
2541
  });
2559
2542
  body.dataStream += "\r";
2560
2543
  }
2561
- (_body$sectionBreaks4 = body.sectionBreaks) === null || _body$sectionBreaks4 === void 0 || _body$sectionBreaks4.push({
2544
+ (_body$sectionBreaks2 = body.sectionBreaks) === null || _body$sectionBreaks2 === void 0 || _body$sectionBreaks2.push({
2562
2545
  sectionId: this._createSectionId(body),
2563
2546
  startIndex: body.dataStream.length
2564
2547
  });
@@ -2573,14 +2556,13 @@ var HtmlToUDMService = class HtmlToUDMService {
2573
2556
  const body = doc.body;
2574
2557
  const element = node;
2575
2558
  if (element.tagName.toUpperCase() === "A") {
2576
- var _body$customRanges, _element$dataset$rang;
2577
2559
  const href = element.href;
2578
2560
  if (!isSafeUrl(href)) return;
2579
- body.customRanges = (_body$customRanges = body.customRanges) !== null && _body$customRanges !== void 0 ? _body$customRanges : [];
2561
+ body.customRanges = body.customRanges ?? [];
2580
2562
  body.customRanges.push({
2581
2563
  startIndex: start,
2582
2564
  endIndex: body.dataStream.length - 1,
2583
- rangeId: (_element$dataset$rang = element.dataset.rangeid) !== null && _element$dataset$rang !== void 0 ? _element$dataset$rang : generateRandomId(),
2565
+ rangeId: element.dataset.rangeid ?? generateRandomId(),
2584
2566
  rangeType: CustomRangeType.HYPERLINK,
2585
2567
  properties: { url: href }
2586
2568
  });
@@ -2598,8 +2580,7 @@ function collectHtmlTableRows(table) {
2598
2580
  return rows;
2599
2581
  }
2600
2582
  function normalizeTextNode(node) {
2601
- var _node$nodeValue;
2602
- const value = (_node$nodeValue = node.nodeValue) !== null && _node$nodeValue !== void 0 ? _node$nodeValue : "";
2583
+ const value = node.nodeValue ?? "";
2603
2584
  if (value.includes(WORD_SPACE_PLACEHOLDER)) return value.replace(/[\t\u00A0]+/g, " ").replace(/[ \r\n]+/g, " ").replace(/ *\uE000+ */g, (match) => " ".repeat(Array.from(match).filter((char) => char === WORD_SPACE_PLACEHOLDER).length));
2604
2585
  const hasExplicitSpacing = /[\t\u00A0]/.test(value);
2605
2586
  const text = value.replace(/[\t\u00A0]+/g, " ").replace(/[ \r\n]+/g, " ");
@@ -2613,9 +2594,9 @@ function inferImageSourceType(src) {
2613
2594
  function hasTextSibling(node, direction) {
2614
2595
  let current = node;
2615
2596
  while (current) {
2616
- var _current$nodeValue, _current$textContent;
2597
+ var _current$nodeValue;
2617
2598
  if (current.nodeType === Node.TEXT_NODE && ((_current$nodeValue = current.nodeValue) === null || _current$nodeValue === void 0 ? void 0 : _current$nodeValue.trim())) return true;
2618
- if (current.nodeType === Node.ELEMENT_NODE && ((_current$textContent = current.textContent) !== null && _current$textContent !== void 0 ? _current$textContent : "").trim()) return true;
2599
+ if (current.nodeType === Node.ELEMENT_NODE && (current.textContent ?? "").trim()) return true;
2619
2600
  current = direction === "previous" ? current.previousSibling : current.nextSibling;
2620
2601
  }
2621
2602
  return false;
@@ -2627,7 +2608,6 @@ function buildHtmlTableGrid(rows) {
2627
2608
  const parsedRow = [];
2628
2609
  let columnIndex = 0;
2629
2610
  getHtmlTableCells(row).forEach((cellElement) => {
2630
- var _cellElement$getAttri, _cellElement$getAttri2;
2631
2611
  while (occupied.has(`${rowIndex}:${columnIndex}`)) {
2632
2612
  parsedRow[columnIndex] = {
2633
2613
  element: null,
@@ -2637,8 +2617,8 @@ function buildHtmlTableGrid(rows) {
2637
2617
  };
2638
2618
  columnIndex++;
2639
2619
  }
2640
- const rowSpan = Math.max(1, Number((_cellElement$getAttri = cellElement.getAttribute("rowspan")) !== null && _cellElement$getAttri !== void 0 ? _cellElement$getAttri : 1));
2641
- const colSpan = Math.max(1, Number((_cellElement$getAttri2 = cellElement.getAttribute("colspan")) !== null && _cellElement$getAttri2 !== void 0 ? _cellElement$getAttri2 : 1));
2620
+ const rowSpan = Math.max(1, Number(cellElement.getAttribute("rowspan") ?? 1));
2621
+ const colSpan = Math.max(1, Number(cellElement.getAttribute("colspan") ?? 1));
2642
2622
  parsedRow[columnIndex] = {
2643
2623
  element: cellElement,
2644
2624
  rowSpan,
@@ -2700,20 +2680,19 @@ function collectHtmlTableColumnWidths(table, grid, columnCount) {
2700
2680
  }
2701
2681
  function resolveHtmlTableColumnWidths(table, grid, columnCount, tableWidth) {
2702
2682
  const explicitWidths = collectHtmlTableColumnWidths(table, grid, columnCount);
2703
- const fallbackTableWidth = tableWidth !== null && tableWidth !== void 0 ? tableWidth : DEFAULT_TABLE_WIDTH;
2704
- const explicitTotal = explicitWidths.reduce((sum, width) => sum + (width !== null && width !== void 0 ? width : 0), 0);
2683
+ const fallbackTableWidth = tableWidth ?? DEFAULT_TABLE_WIDTH;
2684
+ const explicitTotal = explicitWidths.reduce((sum, width) => sum + (width ?? 0), 0);
2705
2685
  const missingCount = explicitWidths.filter((width) => width == null).length;
2706
2686
  const fallbackColumnWidth = missingCount ? Math.max((fallbackTableWidth - explicitTotal) / missingCount, 1) : fallbackTableWidth / columnCount;
2707
- return explicitWidths.map((width) => width !== null && width !== void 0 ? width : roundCssNumber$1(fallbackColumnWidth));
2687
+ return explicitWidths.map((width) => width ?? roundCssNumber$1(fallbackColumnWidth));
2708
2688
  }
2709
2689
  function createTableCellFromHtml(element, rowSpan, colSpan) {
2710
- var _element$getAttribute, _ref, _readCssColor;
2711
2690
  const cell = getEmptyTableCell();
2712
2691
  if (rowSpan > 1) cell.rowSpan = rowSpan;
2713
2692
  if (colSpan > 1) cell.columnSpan = colSpan;
2714
- const style = (_element$getAttribute = element.getAttribute("style")) !== null && _element$getAttribute !== void 0 ? _element$getAttribute : "";
2693
+ const style = element.getAttribute("style") ?? "";
2715
2694
  const width = readCssSize(element.getAttribute("width"), style, "width");
2716
- const backgroundColor = (_ref = (_readCssColor = readCssColor(style, "background-color")) !== null && _readCssColor !== void 0 ? _readCssColor : readCssColor(style, "background")) !== null && _ref !== void 0 ? _ref : readHtmlAttributeColor(element, "bgcolor");
2695
+ const backgroundColor = readCssColor(style, "background-color") ?? readCssColor(style, "background") ?? readHtmlAttributeColor(element, "bgcolor");
2717
2696
  const borderTop = createTableCellBorder(style, "top");
2718
2697
  const borderRight = createTableCellBorder(style, "right");
2719
2698
  const borderBottom = createTableCellBorder(style, "bottom");
@@ -2730,14 +2709,14 @@ function createTableCellFromHtml(element, rowSpan, colSpan) {
2730
2709
  return cell;
2731
2710
  }
2732
2711
  function createTableCellBorder(style, side) {
2733
- var _ref2, _ref3, _ref4, _readCssColor2, _sideStyle$match, _readCssValue, _ref5, _ref6, _readCssLengthValue, _normalizeCssColor;
2712
+ var _sideStyle$match, _readCssValue;
2734
2713
  const sideStyle = readCssValue(style, `border-${side}`);
2735
- const color = (_ref2 = (_ref3 = (_ref4 = (_readCssColor2 = readCssColor(style, `border-${side}-color`)) !== null && _readCssColor2 !== void 0 ? _readCssColor2 : normalizeCssColor$1(sideStyle === null || sideStyle === void 0 || (_sideStyle$match = sideStyle.match(/(#[0-9a-f]{3,8}|rgb\([^)]+\))/i)) === null || _sideStyle$match === void 0 ? void 0 : _sideStyle$match[1])) !== null && _ref4 !== void 0 ? _ref4 : readCssColor(style, "border-color")) !== null && _ref3 !== void 0 ? _ref3 : normalizeCssColor$1((_readCssValue = readCssValue(style, "border")) === null || _readCssValue === void 0 || (_readCssValue = _readCssValue.match(/(#[0-9a-f]{3,8}|rgb\([^)]+\))/i)) === null || _readCssValue === void 0 ? void 0 : _readCssValue[1])) !== null && _ref2 !== void 0 ? _ref2 : readNamedBorderColor(style);
2736
- const width = (_ref5 = (_ref6 = (_readCssLengthValue = readCssLengthValue(readCssValue(style, `border-${side}-width`))) !== null && _readCssLengthValue !== void 0 ? _readCssLengthValue : readCssLengthValue(sideStyle)) !== null && _ref6 !== void 0 ? _ref6 : readCssLengthValue(readCssValue(style, "border-width"))) !== null && _ref5 !== void 0 ? _ref5 : readCssLengthValue(readCssValue(style, "border"));
2714
+ const color = readCssColor(style, `border-${side}-color`) ?? normalizeCssColor$1(sideStyle === null || sideStyle === void 0 || (_sideStyle$match = sideStyle.match(/(#[0-9a-f]{3,8}|rgb\([^)]+\))/i)) === null || _sideStyle$match === void 0 ? void 0 : _sideStyle$match[1]) ?? readCssColor(style, "border-color") ?? normalizeCssColor$1((_readCssValue = readCssValue(style, "border")) === null || _readCssValue === void 0 || (_readCssValue = _readCssValue.match(/(#[0-9a-f]{3,8}|rgb\([^)]+\))/i)) === null || _readCssValue === void 0 ? void 0 : _readCssValue[1]) ?? readNamedBorderColor(style);
2715
+ const width = readCssLengthValue(readCssValue(style, `border-${side}-width`)) ?? readCssLengthValue(sideStyle) ?? readCssLengthValue(readCssValue(style, "border-width")) ?? readCssLengthValue(readCssValue(style, "border"));
2737
2716
  if (!color && width == null) return;
2738
2717
  return {
2739
- color: { rgb: (_normalizeCssColor = normalizeCssColor$1(color)) !== null && _normalizeCssColor !== void 0 ? _normalizeCssColor : "#1f1f1f" },
2740
- width: { v: width !== null && width !== void 0 ? width : 1 }
2718
+ color: { rgb: normalizeCssColor$1(color) ?? "#1f1f1f" },
2719
+ width: { v: width ?? 1 }
2741
2720
  };
2742
2721
  }
2743
2722
  function readNamedBorderColor(style) {
@@ -2781,19 +2760,17 @@ function readCssValue(style, property) {
2781
2760
  }
2782
2761
  function readCssSize(attributeValue, style, property) {
2783
2762
  var _readCssValue2;
2784
- const styleMatch = (_readCssValue2 = readCssValue(style !== null && style !== void 0 ? style : "", property)) === null || _readCssValue2 === void 0 ? void 0 : _readCssValue2.match(/^([0-9.]+)\s*(px|pt|in|cm|mm)?$/i);
2763
+ const styleMatch = (_readCssValue2 = readCssValue(style ?? "", property)) === null || _readCssValue2 === void 0 ? void 0 : _readCssValue2.match(/^([0-9.]+)\s*(px|pt|in|cm|mm)?$/i);
2785
2764
  if (styleMatch) return toPixels(Number(styleMatch[1]), styleMatch[2]);
2786
2765
  const attrMatch = attributeValue === null || attributeValue === void 0 ? void 0 : attributeValue.match(/([0-9.]+)\s*(px|pt|in|cm|mm)?/i);
2787
2766
  return attrMatch ? toPixels(Number(attrMatch[1]), attrMatch[2]) : void 0;
2788
2767
  }
2789
2768
  function readCssLengthValue(value) {
2790
- var _value$match;
2791
- const match = (_value$match = value === null || value === void 0 ? void 0 : value.match(/(?:^|\s)([0-9.]+)\s*(px|pt|in|cm|mm)(?=\s|$)/i)) !== null && _value$match !== void 0 ? _value$match : value === null || value === void 0 ? void 0 : value.match(/^\s*([0-9.]+)\s*$/);
2769
+ const match = (value === null || value === void 0 ? void 0 : value.match(/(?:^|\s)([0-9.]+)\s*(px|pt|in|cm|mm)(?=\s|$)/i)) ?? (value === null || value === void 0 ? void 0 : value.match(/^\s*([0-9.]+)\s*$/));
2792
2770
  return match ? toPixels(Number(match[1]), match[2]) : void 0;
2793
2771
  }
2794
2772
  function readImageSize(element, property) {
2795
- var _readCssSize3;
2796
- return (_readCssSize3 = readCssSize((property === "width" ? element.dataset.width : element.dataset.height) || null, null, property)) !== null && _readCssSize3 !== void 0 ? _readCssSize3 : readCssSize(element.getAttribute(property), element.getAttribute("style"), property);
2773
+ return readCssSize((property === "width" ? element.dataset.width : element.dataset.height) || null, null, property) ?? readCssSize(element.getAttribute(property), element.getAttribute("style"), property);
2797
2774
  }
2798
2775
  function toPixels(value, unit) {
2799
2776
  switch (unit === null || unit === void 0 ? void 0 : unit.toLowerCase()) {
@@ -2841,18 +2818,16 @@ function getHeadingNamedStyleType(node) {
2841
2818
  }
2842
2819
  }
2843
2820
  function extractWordListInfo(node) {
2844
- var _node$getAttribute;
2845
- const match = ((_node$getAttribute = node.getAttribute("style")) !== null && _node$getAttribute !== void 0 ? _node$getAttribute : "").match(/mso-list:\s*([^ ;]+)\s+level(\d+)/i);
2821
+ const match = (node.getAttribute("style") ?? "").match(/mso-list:\s*([^ ;]+)\s+level(\d+)/i);
2846
2822
  if (!match && !/MsoListParagraph/i.test(node.className)) return null;
2847
2823
  {
2848
- var _node$textContent2, _marker$, _match$, _match$2;
2849
- const marker = ((_node$textContent2 = node.textContent) !== null && _node$textContent2 !== void 0 ? _node$textContent2 : "").trim().match(/^([0-9]+[.)]|[a-zA-Z][.)]|[ivxlcdmIVXLCDM]+[.)]|[\u2022\u00B7\u25CF\u25CB\u25AA\u25AB-])/);
2850
- const markerText = (_marker$ = marker === null || marker === void 0 ? void 0 : marker[1]) !== null && _marker$ !== void 0 ? _marker$ : "";
2824
+ const marker = (node.textContent ?? "").trim().match(/^([0-9]+[.)]|[a-zA-Z][.)]|[ivxlcdmIVXLCDM]+[.)]|[\u2022\u00B7\u25CF\u25CB\u25AA\u25AB-])/);
2825
+ const markerText = (marker === null || marker === void 0 ? void 0 : marker[1]) ?? "";
2851
2826
  const ordered = Boolean(markerText && !/^[\u2022\u00B7\u25CF\u25CB\u25AA\u25AB-]$/.test(markerText));
2852
2827
  return {
2853
- listId: (_match$ = match === null || match === void 0 ? void 0 : match[1]) !== null && _match$ !== void 0 ? _match$ : "mso-list",
2828
+ listId: (match === null || match === void 0 ? void 0 : match[1]) ?? "mso-list",
2854
2829
  listType: ordered ? PresetListType.ORDER_LIST : PresetListType.BULLET_LIST,
2855
- nestingLevel: Math.max(0, Number((_match$2 = match === null || match === void 0 ? void 0 : match[2]) !== null && _match$2 !== void 0 ? _match$2 : 1) - 1)
2830
+ nestingLevel: Math.max(0, Number((match === null || match === void 0 ? void 0 : match[2]) ?? 1) - 1)
2856
2831
  };
2857
2832
  }
2858
2833
  }
@@ -3049,12 +3024,12 @@ function readMsoTabCount(attributes) {
3049
3024
  return Number.isFinite(count) ? count : void 0;
3050
3025
  }
3051
3026
  function countWordSpaces(content) {
3052
- var _content$match$length, _content$match, _text$match$reduce, _text$match, _text$replace$match$l, _text$replace$match;
3053
- const entitySpaceCount = (_content$match$length = (_content$match = content.match(/&nbsp;|&#160;|&#x0*a0;/gi)) === null || _content$match === void 0 ? void 0 : _content$match.length) !== null && _content$match$length !== void 0 ? _content$match$length : 0;
3027
+ var _content$match, _text$match, _text$replace$match;
3028
+ const entitySpaceCount = ((_content$match = content.match(/&nbsp;|&#160;|&#x0*a0;/gi)) === null || _content$match === void 0 ? void 0 : _content$match.length) ?? 0;
3054
3029
  const text = content.replace(/&nbsp;|&#160;|&#x0*a0;/gi, "\xA0").replace(/<[^>]*>/g, "");
3055
- const literalSpaceCount = (_text$match$reduce = (_text$match = text.match(/[\u00A0\t]/g)) === null || _text$match === void 0 ? void 0 : _text$match.reduce((count, char) => count + (char === " " ? WORD_TAB_WIDTH : 1), 0)) !== null && _text$match$reduce !== void 0 ? _text$match$reduce : 0;
3030
+ const literalSpaceCount = ((_text$match = text.match(/[\u00A0\t]/g)) === null || _text$match === void 0 ? void 0 : _text$match.reduce((count, char) => count + (char === " " ? WORD_TAB_WIDTH : 1), 0)) ?? 0;
3056
3031
  if (entitySpaceCount || literalSpaceCount) return literalSpaceCount;
3057
- return (_text$replace$match$l = (_text$replace$match = text.replace(/\r?\n/g, "").match(/ /g)) === null || _text$replace$match === void 0 ? void 0 : _text$replace$match.length) !== null && _text$replace$match$l !== void 0 ? _text$replace$match$l : 0;
3032
+ return ((_text$replace$match = text.replace(/\r?\n/g, "").match(/ /g)) === null || _text$replace$match === void 0 ? void 0 : _text$replace$match.length) ?? 0;
3058
3033
  }
3059
3034
 
3060
3035
  //#endregion
@@ -3127,26 +3102,22 @@ function createInternalClipboardDocDataList(docs) {
3127
3102
  if (docs.length === 1) return createInternalClipboardDocData(docs[0]);
3128
3103
  const merged = { body: { dataStream: "" } };
3129
3104
  for (const doc of docs) {
3130
- var _body$dataStream;
3131
3105
  const part = createInternalClipboardDocData(doc);
3132
3106
  const body = part.body;
3133
3107
  if (!body) continue;
3134
3108
  const offset = merged.body.dataStream.length;
3135
- merged.body.dataStream += (_body$dataStream = body.dataStream) !== null && _body$dataStream !== void 0 ? _body$dataStream : "";
3109
+ merged.body.dataStream += body.dataStream ?? "";
3136
3110
  appendOffsetRanges(merged.body, body, offset);
3137
3111
  if (part.tableSource) {
3138
- var _merged$tableSource;
3139
- (_merged$tableSource = merged.tableSource) !== null && _merged$tableSource !== void 0 || (merged.tableSource = {});
3112
+ merged.tableSource ??= {};
3140
3113
  Object.assign(merged.tableSource, part.tableSource);
3141
3114
  }
3142
3115
  if (part.lists) {
3143
- var _merged$lists;
3144
- (_merged$lists = merged.lists) !== null && _merged$lists !== void 0 || (merged.lists = {});
3116
+ merged.lists ??= {};
3145
3117
  Object.assign(merged.lists, part.lists);
3146
3118
  }
3147
3119
  if (part.drawings) {
3148
- var _merged$drawings;
3149
- (_merged$drawings = merged.drawings) !== null && _merged$drawings !== void 0 || (merged.drawings = {});
3120
+ merged.drawings ??= {};
3150
3121
  Object.assign(merged.drawings, part.drawings);
3151
3122
  }
3152
3123
  }
@@ -3181,8 +3152,7 @@ function wrapClipboardHtml(fragmentHtml) {
3181
3152
  function appendOffsetRanges(target, source, offset) {
3182
3153
  var _source$textRuns, _source$paragraphs, _source$sectionBreaks, _source$tables, _source$blockRanges, _source$customRanges, _source$customDecorat, _source$customBlocks;
3183
3154
  if ((_source$textRuns = source.textRuns) === null || _source$textRuns === void 0 ? void 0 : _source$textRuns.length) {
3184
- var _target$textRuns;
3185
- (_target$textRuns = target.textRuns) !== null && _target$textRuns !== void 0 || (target.textRuns = []);
3155
+ target.textRuns ??= [];
3186
3156
  target.textRuns.push(...source.textRuns.map((textRun) => ({
3187
3157
  ...textRun,
3188
3158
  st: textRun.st + offset,
@@ -3190,24 +3160,21 @@ function appendOffsetRanges(target, source, offset) {
3190
3160
  })));
3191
3161
  }
3192
3162
  if ((_source$paragraphs = source.paragraphs) === null || _source$paragraphs === void 0 ? void 0 : _source$paragraphs.length) {
3193
- var _target$paragraphs;
3194
- (_target$paragraphs = target.paragraphs) !== null && _target$paragraphs !== void 0 || (target.paragraphs = []);
3163
+ target.paragraphs ??= [];
3195
3164
  target.paragraphs.push(...source.paragraphs.map((paragraph) => ({
3196
3165
  ...paragraph,
3197
3166
  startIndex: paragraph.startIndex + offset
3198
3167
  })));
3199
3168
  }
3200
3169
  if ((_source$sectionBreaks = source.sectionBreaks) === null || _source$sectionBreaks === void 0 ? void 0 : _source$sectionBreaks.length) {
3201
- var _target$sectionBreaks;
3202
- (_target$sectionBreaks = target.sectionBreaks) !== null && _target$sectionBreaks !== void 0 || (target.sectionBreaks = []);
3170
+ target.sectionBreaks ??= [];
3203
3171
  target.sectionBreaks.push(...source.sectionBreaks.map((sectionBreak) => ({
3204
3172
  ...sectionBreak,
3205
3173
  startIndex: sectionBreak.startIndex + offset
3206
3174
  })));
3207
3175
  }
3208
3176
  if ((_source$tables = source.tables) === null || _source$tables === void 0 ? void 0 : _source$tables.length) {
3209
- var _target$tables;
3210
- (_target$tables = target.tables) !== null && _target$tables !== void 0 || (target.tables = []);
3177
+ target.tables ??= [];
3211
3178
  target.tables.push(...source.tables.map((table) => ({
3212
3179
  ...table,
3213
3180
  startIndex: table.startIndex + offset,
@@ -3215,8 +3182,7 @@ function appendOffsetRanges(target, source, offset) {
3215
3182
  })));
3216
3183
  }
3217
3184
  if ((_source$blockRanges = source.blockRanges) === null || _source$blockRanges === void 0 ? void 0 : _source$blockRanges.length) {
3218
- var _target$blockRanges;
3219
- (_target$blockRanges = target.blockRanges) !== null && _target$blockRanges !== void 0 || (target.blockRanges = []);
3185
+ target.blockRanges ??= [];
3220
3186
  target.blockRanges.push(...source.blockRanges.map((blockRange) => ({
3221
3187
  ...blockRange,
3222
3188
  startIndex: blockRange.startIndex + offset,
@@ -3224,8 +3190,7 @@ function appendOffsetRanges(target, source, offset) {
3224
3190
  })));
3225
3191
  }
3226
3192
  if ((_source$customRanges = source.customRanges) === null || _source$customRanges === void 0 ? void 0 : _source$customRanges.length) {
3227
- var _target$customRanges;
3228
- (_target$customRanges = target.customRanges) !== null && _target$customRanges !== void 0 || (target.customRanges = []);
3193
+ target.customRanges ??= [];
3229
3194
  target.customRanges.push(...source.customRanges.map((customRange) => ({
3230
3195
  ...customRange,
3231
3196
  startIndex: customRange.startIndex + offset,
@@ -3233,8 +3198,7 @@ function appendOffsetRanges(target, source, offset) {
3233
3198
  })));
3234
3199
  }
3235
3200
  if ((_source$customDecorat = source.customDecorations) === null || _source$customDecorat === void 0 ? void 0 : _source$customDecorat.length) {
3236
- var _target$customDecorat;
3237
- (_target$customDecorat = target.customDecorations) !== null && _target$customDecorat !== void 0 || (target.customDecorations = []);
3201
+ target.customDecorations ??= [];
3238
3202
  target.customDecorations.push(...source.customDecorations.map((customDecoration) => ({
3239
3203
  ...customDecoration,
3240
3204
  startIndex: customDecoration.startIndex + offset,
@@ -3242,8 +3206,7 @@ function appendOffsetRanges(target, source, offset) {
3242
3206
  })));
3243
3207
  }
3244
3208
  if ((_source$customBlocks = source.customBlocks) === null || _source$customBlocks === void 0 ? void 0 : _source$customBlocks.length) {
3245
- var _target$customBlocks;
3246
- (_target$customBlocks = target.customBlocks) !== null && _target$customBlocks !== void 0 || (target.customBlocks = []);
3209
+ target.customBlocks ??= [];
3247
3210
  target.customBlocks.push(...source.customBlocks.map((customBlock) => ({
3248
3211
  ...customBlock,
3249
3212
  startIndex: customBlock.startIndex + offset
@@ -3290,7 +3253,7 @@ function covertTextRunToHtml(dataStream, textRun) {
3290
3253
  if ((ul === null || ul === void 0 ? void 0 : ul.s) === BooleanNumber.TRUE) html = `<u>${html}</u>`;
3291
3254
  if ((st === null || st === void 0 ? void 0 : st.s) === BooleanNumber.TRUE) html = `<s>${html}</s>`;
3292
3255
  if (bl === BooleanNumber.TRUE) html = `<strong>${html}</strong>`;
3293
- style.push(`font-family: ${ff !== null && ff !== void 0 ? ff : DEFAULT_CLIPBOARD_FONT_FAMILY}`);
3256
+ style.push(`font-family: ${ff ?? DEFAULT_CLIPBOARD_FONT_FAMILY}`);
3294
3257
  if (cl === null || cl === void 0 ? void 0 : cl.rgb) style.push(`color: ${normalizeCssColor(cl.rgb)}`);
3295
3258
  if (fs) style.push(`font-size: ${fs}pt`);
3296
3259
  if (ol) style.push("text-decoration: overline");
@@ -3367,8 +3330,8 @@ function getBodySliceHtml(doc, startIndex, endIndex) {
3367
3330
  const sliceHtml = handleCustomBlock(startIndex, endIndex + 1);
3368
3331
  switch (rangeType) {
3369
3332
  case CustomRangeType.HYPERLINK:
3370
- var _range$properties$url, _range$properties;
3371
- html += `<a data-rangeid="${rangeId}" href="${(_range$properties$url = (_range$properties = range.properties) === null || _range$properties === void 0 ? void 0 : _range$properties.url) !== null && _range$properties$url !== void 0 ? _range$properties$url : ""}">${sliceHtml.sliceHtml}</a>`;
3333
+ var _range$properties;
3334
+ html += `<a data-rangeid="${rangeId}" href="${((_range$properties = range.properties) === null || _range$properties === void 0 ? void 0 : _range$properties.url) ?? ""}">${sliceHtml.sliceHtml}</a>`;
3372
3335
  break;
3373
3336
  default:
3374
3337
  html += sliceHtml.sliceHtml;
@@ -3410,9 +3373,9 @@ function processNode(node, doc, result) {
3410
3373
  for (const n of node.children) processNode(n, doc, result);
3411
3374
  break;
3412
3375
  case DataStreamTreeNodeType.PARAGRAPH: {
3413
- var _doc$body$paragraphs$, _doc$body;
3376
+ var _doc$body;
3414
3377
  const { children, startIndex, endIndex } = node;
3415
- const paragraph = (_doc$body$paragraphs$ = (_doc$body = doc.body) === null || _doc$body === void 0 || (_doc$body = _doc$body.paragraphs) === null || _doc$body === void 0 ? void 0 : _doc$body.find((p) => p.startIndex === endIndex)) !== null && _doc$body$paragraphs$ !== void 0 ? _doc$body$paragraphs$ : {};
3378
+ const paragraph = ((_doc$body = doc.body) === null || _doc$body === void 0 || (_doc$body = _doc$body.paragraphs) === null || _doc$body === void 0 ? void 0 : _doc$body.find((p) => p.startIndex === endIndex)) ?? {};
3416
3379
  const { paragraphStyle = {} } = paragraph;
3417
3380
  const { horizontalAlign, spaceAbove, spaceBelow, lineSpacing } = paragraphStyle;
3418
3381
  const style = [];
@@ -3443,16 +3406,16 @@ function processNode(node, doc, result) {
3443
3406
  break;
3444
3407
  }
3445
3408
  case DataStreamTreeNodeType.TABLE: {
3446
- var _result$tableIndex, _result$tableStack, _doc$body2, _doc$tableSource, _table$tableColumns;
3409
+ var _doc$body2, _doc$tableSource, _table$tableColumns;
3447
3410
  const { children } = node;
3448
3411
  closeListStack(result);
3449
- (_result$tableIndex = result.tableIndex) !== null && _result$tableIndex !== void 0 || (result.tableIndex = 0);
3450
- (_result$tableStack = result.tableStack) !== null && _result$tableStack !== void 0 || (result.tableStack = []);
3412
+ result.tableIndex ??= 0;
3413
+ result.tableStack ??= [];
3451
3414
  const tableRange = (_doc$body2 = doc.body) === null || _doc$body2 === void 0 || (_doc$body2 = _doc$body2.tables) === null || _doc$body2 === void 0 ? void 0 : _doc$body2[result.tableIndex++];
3452
3415
  const table = tableRange ? (_doc$tableSource = doc.tableSource) === null || _doc$tableSource === void 0 ? void 0 : _doc$tableSource[tableRange.tableId] : void 0;
3453
3416
  const width = table === null || table === void 0 || (_table$tableColumns = table.tableColumns) === null || _table$tableColumns === void 0 ? void 0 : _table$tableColumns.reduce((sum, column) => {
3454
- var _column$size$width$v, _column$size;
3455
- return sum + ((_column$size$width$v = (_column$size = column.size) === null || _column$size === void 0 || (_column$size = _column$size.width) === null || _column$size === void 0 ? void 0 : _column$size.v) !== null && _column$size$width$v !== void 0 ? _column$size$width$v : 0);
3417
+ var _column$size;
3418
+ return sum + (((_column$size = column.size) === null || _column$size === void 0 || (_column$size = _column$size.width) === null || _column$size === void 0 ? void 0 : _column$size.v) ?? 0);
3456
3419
  }, 0);
3457
3420
  const tableStyle = ["border-collapse: collapse", width ? `width: ${roundCssNumber(width)}px` : "width: 100%"].join("; ");
3458
3421
  result.tableStack.push({
@@ -3467,9 +3430,9 @@ function processNode(node, doc, result) {
3467
3430
  break;
3468
3431
  }
3469
3432
  case DataStreamTreeNodeType.TABLE_ROW: {
3470
- var _result$tableStack2, _tableContext$table, _row$trHeight;
3433
+ var _result$tableStack, _tableContext$table, _row$trHeight;
3471
3434
  const { children } = node;
3472
- const tableContext = (_result$tableStack2 = result.tableStack) === null || _result$tableStack2 === void 0 ? void 0 : _result$tableStack2[result.tableStack.length - 1];
3435
+ const tableContext = (_result$tableStack = result.tableStack) === null || _result$tableStack === void 0 ? void 0 : _result$tableStack[result.tableStack.length - 1];
3473
3436
  if (tableContext) {
3474
3437
  tableContext.rowIndex++;
3475
3438
  tableContext.columnIndex = 0;
@@ -3482,11 +3445,11 @@ function processNode(node, doc, result) {
3482
3445
  break;
3483
3446
  }
3484
3447
  case DataStreamTreeNodeType.TABLE_CELL: {
3485
- var _result$tableStack3, _tableContext$table2, _row$tableCells, _tableContext$columnI;
3448
+ var _result$tableStack2, _tableContext$table2, _row$tableCells;
3486
3449
  const { children } = node;
3487
- const tableContext = (_result$tableStack3 = result.tableStack) === null || _result$tableStack3 === void 0 ? void 0 : _result$tableStack3[result.tableStack.length - 1];
3450
+ const tableContext = (_result$tableStack2 = result.tableStack) === null || _result$tableStack2 === void 0 ? void 0 : _result$tableStack2[result.tableStack.length - 1];
3488
3451
  const row = tableContext === null || tableContext === void 0 || (_tableContext$table2 = tableContext.table) === null || _tableContext$table2 === void 0 || (_tableContext$table2 = _tableContext$table2.tableRows) === null || _tableContext$table2 === void 0 ? void 0 : _tableContext$table2[tableContext.rowIndex];
3489
- const cell = row === null || row === void 0 || (_row$tableCells = row.tableCells) === null || _row$tableCells === void 0 ? void 0 : _row$tableCells[(_tableContext$columnI = tableContext === null || tableContext === void 0 ? void 0 : tableContext.columnIndex) !== null && _tableContext$columnI !== void 0 ? _tableContext$columnI : 0];
3452
+ const cell = row === null || row === void 0 || (_row$tableCells = row.tableCells) === null || _row$tableCells === void 0 ? void 0 : _row$tableCells[(tableContext === null || tableContext === void 0 ? void 0 : tableContext.columnIndex) ?? 0];
3490
3453
  if (tableContext) tableContext.columnIndex++;
3491
3454
  if ((cell === null || cell === void 0 ? void 0 : cell.rowSpan) === 0 || (cell === null || cell === void 0 ? void 0 : cell.columnSpan) === 0) break;
3492
3455
  result.html += `<td class="UniverTableCell"${serializeTableCellAttributes(cell)}>`;
@@ -3508,10 +3471,10 @@ function renderParagraphNodeHtml(doc, paragraph, startIndex, endIndex, innerHtml
3508
3471
  result.html += renderBlockParagraphHtml(doc, paragraph, startIndex, endIndex, innerHtml, style);
3509
3472
  }
3510
3473
  function renderBlockParagraphHtml(doc, paragraph, startIndex, endIndex, innerHtml, style) {
3511
- var _doc$body3, _renderHeadingParagra;
3474
+ var _doc$body3;
3512
3475
  const blockRange = (_doc$body3 = doc.body) === null || _doc$body3 === void 0 || (_doc$body3 = _doc$body3.blockRanges) === null || _doc$body3 === void 0 ? void 0 : _doc$body3.find((range) => range.startIndex <= startIndex && endIndex <= range.endIndex + 1);
3513
3476
  if (blockRange && !hasVisibleHtml(innerHtml)) return "";
3514
- const paragraphHtml = (_renderHeadingParagra = renderHeadingParagraphHtml(paragraph, innerHtml, style)) !== null && _renderHeadingParagra !== void 0 ? _renderHeadingParagra : `<p class="UniverNormal" ${style.length ? `style="${style.join("; ")};"` : ""}>${innerHtml}</p>`;
3477
+ const paragraphHtml = renderHeadingParagraphHtml(paragraph, innerHtml, style) ?? `<p class="UniverNormal" ${style.length ? `style="${style.join("; ")};"` : ""}>${innerHtml}</p>`;
3515
3478
  switch (blockRange === null || blockRange === void 0 ? void 0 : blockRange.blockType) {
3516
3479
  case DocumentBlockRangeType.QUOTE: return `<blockquote data-doc-type="quote" style="border-left: 4px solid #d0d7de; margin: 8px 0; padding: 4px 0 4px 12px; color: #57606a;">${paragraphHtml}</blockquote>`;
3517
3480
  case DocumentBlockRangeType.CODE: return `<pre data-doc-type="code-block" style="font-family: Consolas, 'Courier New', monospace; background: #f6f8fa; padding: 12px; border-radius: 6px; white-space: pre-wrap;"><code>${innerHtml.replace(/<\/?[^>]+>/g, "")}</code></pre>`;
@@ -3526,11 +3489,10 @@ function renderHeadingParagraphHtml(paragraph, innerHtml, style) {
3526
3489
  return `<p class="UniverHeading" role="heading" aria-level="${headingLevel}" data-heading-level="${headingLevel}" ${style.length ? `style="${style.join("; ")};"` : ""}>${innerHtml}</p>`;
3527
3490
  }
3528
3491
  function renderListParagraphItemHtml(doc, paragraph, innerHtml, style) {
3529
- var _bullet$nestingLevel;
3530
3492
  const bullet = paragraph.bullet;
3531
3493
  if (!bullet) return null;
3532
3494
  const tag = isOrderedListType(String(bullet.listType)) ? "ol" : "ul";
3533
- const level = (_bullet$nestingLevel = bullet.nestingLevel) !== null && _bullet$nestingLevel !== void 0 ? _bullet$nestingLevel : 0;
3495
+ const level = bullet.nestingLevel ?? 0;
3534
3496
  const listStyle = getListStyleType(doc, String(bullet.listType), level);
3535
3497
  return {
3536
3498
  tag,
@@ -3541,8 +3503,7 @@ function renderListParagraphItemHtml(doc, paragraph, innerHtml, style) {
3541
3503
  };
3542
3504
  }
3543
3505
  function appendListParagraphHtml(result, listItem) {
3544
- var _result$listStack;
3545
- (_result$listStack = result.listStack) !== null && _result$listStack !== void 0 || (result.listStack = []);
3506
+ result.listStack ??= [];
3546
3507
  const stack = result.listStack;
3547
3508
  while (stack.length > listItem.level + 1) result.html += `</li></${stack.pop().tag}>`;
3548
3509
  const current = stack[stack.length - 1];
@@ -3571,16 +3532,16 @@ function openList(result, listItem) {
3571
3532
  });
3572
3533
  }
3573
3534
  function closeListStack(result) {
3574
- var _result$listStack2;
3575
- while ((_result$listStack2 = result.listStack) === null || _result$listStack2 === void 0 ? void 0 : _result$listStack2.length) result.html += `</li></${result.listStack.pop().tag}>`;
3535
+ var _result$listStack;
3536
+ while ((_result$listStack = result.listStack) === null || _result$listStack === void 0 ? void 0 : _result$listStack.length) result.html += `</li></${result.listStack.pop().tag}>`;
3576
3537
  }
3577
3538
  function serializeTableCellAttributes(cell) {
3578
- var _cell$rowSpan, _cell$columnSpan, _cell$size, _cell$backgroundColor;
3539
+ var _cell$size, _cell$backgroundColor;
3579
3540
  if (!cell) return "";
3580
3541
  const attributes = [];
3581
3542
  const styles = [];
3582
- if (((_cell$rowSpan = cell.rowSpan) !== null && _cell$rowSpan !== void 0 ? _cell$rowSpan : 1) > 1) attributes.push(`rowspan="${cell.rowSpan}"`);
3583
- if (((_cell$columnSpan = cell.columnSpan) !== null && _cell$columnSpan !== void 0 ? _cell$columnSpan : 1) > 1) attributes.push(`colspan="${cell.columnSpan}"`);
3543
+ if ((cell.rowSpan ?? 1) > 1) attributes.push(`rowspan="${cell.rowSpan}"`);
3544
+ if ((cell.columnSpan ?? 1) > 1) attributes.push(`colspan="${cell.columnSpan}"`);
3584
3545
  if (((_cell$size = cell.size) === null || _cell$size === void 0 || (_cell$size = _cell$size.width) === null || _cell$size === void 0 ? void 0 : _cell$size.v) != null) styles.push(`width: ${roundCssNumber(cell.size.width.v)}px`);
3585
3546
  if ((_cell$backgroundColor = cell.backgroundColor) === null || _cell$backgroundColor === void 0 ? void 0 : _cell$backgroundColor.rgb) styles.push(`background-color: ${cell.backgroundColor.rgb}`);
3586
3547
  [
@@ -3589,9 +3550,9 @@ function serializeTableCellAttributes(cell) {
3589
3550
  ["bottom", cell.borderBottom],
3590
3551
  ["left", cell.borderLeft]
3591
3552
  ].forEach(([side, border]) => {
3592
- var _border$width$v, _border$width, _border$color$rgb, _border$color;
3553
+ var _border$width, _border$color;
3593
3554
  if (!border) return;
3594
- styles.push(`border-${side}: ${roundCssNumber((_border$width$v = (_border$width = border.width) === null || _border$width === void 0 ? void 0 : _border$width.v) !== null && _border$width$v !== void 0 ? _border$width$v : 1)}px solid ${(_border$color$rgb = (_border$color = border.color) === null || _border$color === void 0 ? void 0 : _border$color.rgb) !== null && _border$color$rgb !== void 0 ? _border$color$rgb : "#1f1f1f"}`);
3555
+ styles.push(`border-${side}: ${roundCssNumber(((_border$width = border.width) === null || _border$width === void 0 ? void 0 : _border$width.v) ?? 1)}px solid ${((_border$color = border.color) === null || _border$color === void 0 ? void 0 : _border$color.rgb) ?? "#1f1f1f"}`);
3595
3556
  });
3596
3557
  if (styles.length) attributes.push(`style="${styles.join("; ")};"`);
3597
3558
  return attributes.length ? ` ${attributes.join(" ")}` : "";
@@ -3600,7 +3561,7 @@ function serializeTextStyle(textStyle) {
3600
3561
  if (!textStyle) return [];
3601
3562
  const { ff, fs, it, bl, ul, st, ol, bg, cl } = textStyle;
3602
3563
  const style = [];
3603
- style.push(`font-family: ${ff !== null && ff !== void 0 ? ff : DEFAULT_CLIPBOARD_FONT_FAMILY}`);
3564
+ style.push(`font-family: ${ff ?? DEFAULT_CLIPBOARD_FONT_FAMILY}`);
3604
3565
  if (fs != null) style.push(`font-size: ${fs}pt`);
3605
3566
  if (cl === null || cl === void 0 ? void 0 : cl.rgb) style.push(`color: ${normalizeCssColor(cl.rgb)}`);
3606
3567
  if (bg === null || bg === void 0 ? void 0 : bg.rgb) style.push(`background-color: ${normalizeCssColor(bg.rgb)}`);
@@ -3685,8 +3646,8 @@ var UDMToHtmlService = class {
3685
3646
  if (docList.length === 0) throw new Error("The bodyList length at least to be 1");
3686
3647
  let html = "";
3687
3648
  for (const doc of Tools.deepClone(docList)) {
3688
- var _this$_docHtmlExportS, _this$_docHtmlExportS2;
3689
- html += convertBodyToHtml((_this$_docHtmlExportS = (_this$_docHtmlExportS2 = this._docHtmlExportService) === null || _this$_docHtmlExportS2 === void 0 ? void 0 : _this$_docHtmlExportS2.transformDocumentForHtmlExport(doc)) !== null && _this$_docHtmlExportS !== void 0 ? _this$_docHtmlExportS : doc);
3649
+ var _this$_docHtmlExportS;
3650
+ html += convertBodyToHtml(((_this$_docHtmlExportS = this._docHtmlExportService) === null || _this$_docHtmlExportS === void 0 ? void 0 : _this$_docHtmlExportS.transformDocumentForHtmlExport(doc)) ?? doc);
3690
3651
  }
3691
3652
  return html;
3692
3653
  }
@@ -3759,8 +3720,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
3759
3720
  this._umdToHtml = new UDMToHtmlService(docHtmlExportService);
3760
3721
  }
3761
3722
  async copy(sliceType = SliceBodyType.copy, ranges) {
3762
- var _this$_getDocumentBod;
3763
- const { newSnapshotList = [], needCache = false, plainTextList, snapshot, ranges: allRanges } = (_this$_getDocumentBod = this._getDocumentBodyInRanges(sliceType, ranges)) !== null && _this$_getDocumentBod !== void 0 ? _this$_getDocumentBod : {};
3723
+ const { newSnapshotList = [], needCache = false, plainTextList, snapshot, ranges: allRanges } = this._getDocumentBodyInRanges(sliceType, ranges) ?? {};
3764
3724
  if (newSnapshotList.length === 0 || snapshot == null) return false;
3765
3725
  try {
3766
3726
  var _allRanges$;
@@ -3799,10 +3759,9 @@ let DocClipboardService = class DocClipboardService extends Disposable {
3799
3759
  return this._paste(partDocData);
3800
3760
  }
3801
3761
  async _cut(ranges) {
3802
- var _ref, _ranges$filter, _ref2, _ref3, _textRanges$;
3803
- const textRanges = (_ref = (_ranges$filter = ranges === null || ranges === void 0 ? void 0 : ranges.filter((range) => range.rangeType === DOC_RANGE_TYPE.TEXT)) !== null && _ranges$filter !== void 0 ? _ranges$filter : this._docSelectionManagerService.getTextRanges()) !== null && _ref !== void 0 ? _ref : [];
3804
- const rectRanges = (_ref2 = (_ref3 = ranges === null || ranges === void 0 ? void 0 : ranges.filter((range) => range.rangeType === DOC_RANGE_TYPE.RECT)) !== null && _ref3 !== void 0 ? _ref3 : this._docSelectionManagerService.getRectRanges()) !== null && _ref2 !== void 0 ? _ref2 : [];
3805
- const { segmentId, endOffset: activeEndOffset, style } = (_textRanges$ = textRanges[0]) !== null && _textRanges$ !== void 0 ? _textRanges$ : {};
3762
+ const textRanges = (ranges === null || ranges === void 0 ? void 0 : ranges.filter((range) => range.rangeType === DOC_RANGE_TYPE.TEXT)) ?? this._docSelectionManagerService.getTextRanges() ?? [];
3763
+ const rectRanges = (ranges === null || ranges === void 0 ? void 0 : ranges.filter((range) => range.rangeType === DOC_RANGE_TYPE.RECT)) ?? this._docSelectionManagerService.getRectRanges() ?? [];
3764
+ const { segmentId, endOffset: activeEndOffset, style } = textRanges[0] ?? {};
3806
3765
  if (segmentId == null) this._logService.error("[DocClipboardController] segmentId is not existed");
3807
3766
  if (textRanges.length === 0 && rectRanges.length === 0) return false;
3808
3767
  this.copy(SliceBodyType.cut, ranges);
@@ -3834,7 +3793,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
3834
3793
  }
3835
3794
  }
3836
3795
  async _paste(docData) {
3837
- var _body$customRanges$ma, _body$customRanges, _body$paragraphs, _currentDocument$getS;
3796
+ var _body$customRanges, _body$paragraphs, _currentDocument$getS;
3838
3797
  const { body: _body } = docData;
3839
3798
  if (_body == null) return false;
3840
3799
  let body = normalizeBody(_body);
@@ -3846,12 +3805,12 @@ let DocClipboardService = class DocClipboardService extends Disposable {
3846
3805
  targetUnitId: currentDocument.getUnitId()
3847
3806
  });
3848
3807
  });
3849
- const customRangeMappings = (_body$customRanges$ma = (_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.map((sourceRange) => {
3808
+ const customRangeMappings = ((_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.map((sourceRange) => {
3850
3809
  return {
3851
3810
  sourceRange,
3852
3811
  targetRange: BuildTextUtils.customRange.copyCustomRange(sourceRange)
3853
3812
  };
3854
- })) !== null && _body$customRanges$ma !== void 0 ? _body$customRanges$ma : [];
3813
+ })) ?? [];
3855
3814
  body.customRanges = customRangeMappings.map(({ targetRange }) => targetRange);
3856
3815
  (_body$paragraphs = body.paragraphs) === null || _body$paragraphs === void 0 || _body$paragraphs.forEach((copy) => {
3857
3816
  var _copy$paragraphStyle;
@@ -3924,14 +3883,14 @@ let DocClipboardService = class DocClipboardService extends Disposable {
3924
3883
  }
3925
3884
  _applyCopyDocDataHooks(doc, sourceDocuments) {
3926
3885
  return this._clipboardHooks.reduce((currentDoc, hook) => {
3927
- var _hook$onCopyDocData, _hook$onCopyDocData2;
3928
- return (_hook$onCopyDocData = (_hook$onCopyDocData2 = hook.onCopyDocData) === null || _hook$onCopyDocData2 === void 0 ? void 0 : _hook$onCopyDocData2.call(hook, currentDoc, { sourceDocuments })) !== null && _hook$onCopyDocData !== void 0 ? _hook$onCopyDocData : currentDoc;
3886
+ var _hook$onCopyDocData;
3887
+ return ((_hook$onCopyDocData = hook.onCopyDocData) === null || _hook$onCopyDocData === void 0 ? void 0 : _hook$onCopyDocData.call(hook, currentDoc, { sourceDocuments })) ?? currentDoc;
3929
3888
  }, doc);
3930
3889
  }
3931
3890
  _getDocumentBodyInRanges(sliceType, ranges) {
3932
3891
  var _this$_clipboardHooks, _docDataModel$getSelf;
3933
3892
  const docDataModel = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
3934
- const allRanges = ranges !== null && ranges !== void 0 ? ranges : this._docSelectionManagerService.getDocRanges();
3893
+ const allRanges = ranges ?? this._docSelectionManagerService.getDocRanges();
3935
3894
  const results = [];
3936
3895
  const plainTextResults = [];
3937
3896
  const copyContentHook = (_this$_clipboardHooks = this._clipboardHooks.find((hook) => hook.onCopyContent)) === null || _this$_clipboardHooks === void 0 ? void 0 : _this$_clipboardHooks.onCopyContent;
@@ -3942,7 +3901,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
3942
3901
  const snapshot = docDataModel.getSnapshot();
3943
3902
  if (body == null) return;
3944
3903
  for (const range of allRanges) {
3945
- var _docDataModel$getSelf2, _copyContentHook;
3904
+ var _docDataModel$getSelf2;
3946
3905
  const { startOffset, endOffset, collapsed, rangeType } = range;
3947
3906
  if (collapsed || startOffset == null || endOffset == null) continue;
3948
3907
  if (rangeType === DOC_RANGE_TYPE.RECT) {
@@ -3960,11 +3919,11 @@ let DocClipboardService = class DocClipboardService extends Disposable {
3960
3919
  const docBody = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.sliceBody(deleteRange.startOffset, deleteRange.endOffset, sliceType);
3961
3920
  if (docBody == null) continue;
3962
3921
  results.push(docBody);
3963
- plainTextResults.push((_copyContentHook = copyContentHook === null || copyContentHook === void 0 ? void 0 : copyContentHook(deleteRange.startOffset, deleteRange.endOffset, {
3922
+ plainTextResults.push((copyContentHook === null || copyContentHook === void 0 ? void 0 : copyContentHook(deleteRange.startOffset, deleteRange.endOffset, {
3964
3923
  body,
3965
3924
  segmentId,
3966
3925
  unitId: docDataModel.getUnitId()
3967
- })) !== null && _copyContentHook !== void 0 ? _copyContentHook : docBody.dataStream);
3926
+ })) ?? docBody.dataStream);
3968
3927
  }
3969
3928
  return {
3970
3929
  newSnapshotList: results.map((e) => ({
@@ -3979,7 +3938,6 @@ let DocClipboardService = class DocClipboardService extends Disposable {
3979
3938
  }
3980
3939
  async _genDocDataFromClipboardItems(items) {
3981
3940
  try {
3982
- var _await$this$_uploadBa;
3983
3941
  let html = "";
3984
3942
  let text = "";
3985
3943
  let internalJson = "";
@@ -4005,15 +3963,14 @@ let DocClipboardService = class DocClipboardService extends Disposable {
4005
3963
  }
4006
3964
  }
4007
3965
  if (!html && !text && files.length) html = await this._createImagePasteHtml(files);
4008
- html = (_await$this$_uploadBa = await this._uploadBase64ImagesInHtml(html)) !== null && _await$this$_uploadBa !== void 0 ? _await$this$_uploadBa : "";
3966
+ html = await this._uploadBase64ImagesInHtml(html) ?? "";
4009
3967
  return this._genDocDataFromHtmlAndText(html, text, void 0, internalJson);
4010
3968
  } catch (e) {
4011
3969
  return Promise.reject(e);
4012
3970
  }
4013
3971
  }
4014
3972
  _genDocDataFromHtmlAndText(html, text, _unitId, internalJson) {
4015
- var _parseInternalClipboa;
4016
- const internalDocData = (_parseInternalClipboa = parseInternalClipboardFragment(internalJson)) !== null && _parseInternalClipboa !== void 0 ? _parseInternalClipboa : extractInternalClipboardFragmentFromHtml(html);
3973
+ const internalDocData = parseInternalClipboardFragment(internalJson) ?? extractInternalClipboardFragmentFromHtml(html);
4017
3974
  if (internalDocData === null || internalDocData === void 0 ? void 0 : internalDocData.body) return internalDocData;
4018
3975
  if (!html) if (text) return { body: BuildTextUtils.transform.fromPlainText(text) };
4019
3976
  else throw new Error("[DocClipboardService] html and text cannot be both empty!");
@@ -4055,7 +4012,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
4055
4012
  return doc.documentElement.outerHTML;
4056
4013
  }
4057
4014
  async _createImagePasteHtml(files) {
4058
- var _this$_clipboardHooks3, _this$_clipboardHooks4;
4015
+ var _this$_clipboardHooks3;
4059
4016
  const doc = {
4060
4017
  id: "",
4061
4018
  documentStyle: {},
@@ -4091,7 +4048,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
4091
4048
  };
4092
4049
  });
4093
4050
  };
4094
- 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;
4051
+ const onBeforePasteImage = ((_this$_clipboardHooks3 = this._clipboardHooks.find((e) => e.onBeforePasteImage)) === null || _this$_clipboardHooks3 === void 0 ? void 0 : _this$_clipboardHooks3.onBeforePasteImage) ?? fileToBase64;
4095
4052
  await Promise.all(files.map(async (file, index) => {
4096
4053
  var _body$customBlocks;
4097
4054
  const image = await onBeforePasteImage(file);
@@ -4153,12 +4110,12 @@ function endsAtDocumentBoundary(dataStream) {
4153
4110
  return lastToken === DataStreamTreeTokenType.PARAGRAPH || lastToken === DataStreamTreeTokenType.SECTION_BREAK || lastToken === DataStreamTreeTokenType.BLOCK_END || lastToken === DataStreamTreeTokenType.TABLE_END || lastToken === DataStreamTreeTokenType.COLUMN_GROUP_END;
4154
4111
  }
4155
4112
  function ensureParagraphAtStructuralGap(body, originBody, ranges) {
4156
- var _body$paragraphs$map, _body$paragraphs2, _body$paragraphs3;
4113
+ var _body$paragraphs2;
4157
4114
  if (endsAtDocumentBoundary(body.dataStream) || !ranges.every((range) => range.collapsed && isTopLevelStructuralGap(originBody.dataStream, range.startOffset))) return;
4158
4115
  const paragraphIndex = body.dataStream.length;
4159
- const paragraphIds = new Set((_body$paragraphs$map = (_body$paragraphs2 = body.paragraphs) === null || _body$paragraphs2 === void 0 ? void 0 : _body$paragraphs2.map((paragraph) => paragraph.paragraphId)) !== null && _body$paragraphs$map !== void 0 ? _body$paragraphs$map : []);
4116
+ const paragraphIds = new Set(((_body$paragraphs2 = body.paragraphs) === null || _body$paragraphs2 === void 0 ? void 0 : _body$paragraphs2.map((paragraph) => paragraph.paragraphId)) ?? []);
4160
4117
  body.dataStream += DataStreamTreeTokenType.PARAGRAPH;
4161
- body.paragraphs = [...(_body$paragraphs3 = body.paragraphs) !== null && _body$paragraphs3 !== void 0 ? _body$paragraphs3 : [], {
4118
+ body.paragraphs = [...body.paragraphs ?? [], {
4162
4119
  startIndex: paragraphIndex,
4163
4120
  paragraphId: createParagraphId(paragraphIds)
4164
4121
  }];
@@ -4568,12 +4525,12 @@ const DocSelectAllCommand = {
4568
4525
  id: "doc.command.select-all",
4569
4526
  type: CommandType.COMMAND,
4570
4527
  handler: async (accessor) => {
4571
- var _docRanges$find, _docDataModel$getSelf;
4528
+ var _docDataModel$getSelf;
4572
4529
  const univerInstanceService = accessor.get(IUniverInstanceService);
4573
4530
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
4574
4531
  const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
4575
4532
  const docRanges = docSelectionManagerService.getDocRanges();
4576
- const activeRange = (_docRanges$find = docRanges.find((range) => range.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
4533
+ const activeRange = docRanges.find((range) => range.isActive) ?? docRanges[0];
4577
4534
  if (docDataModel == null || activeRange == null) return false;
4578
4535
  const { segmentId } = activeRange;
4579
4536
  const unitId = docDataModel.getUnitId();
@@ -4595,8 +4552,7 @@ function getWholeDocumentRanges(body) {
4595
4552
  return getRangesForOffsets(body, 0, body.dataStream.length - 2);
4596
4553
  }
4597
4554
  function getRangesForOffsets(body, startOffset, endOffset) {
4598
- var _body$columnGroups;
4599
- const columnGroups = [...(_body$columnGroups = body.columnGroups) !== null && _body$columnGroups !== void 0 ? _body$columnGroups : []].sort((left, right) => left.startIndex - right.startIndex);
4555
+ const columnGroups = [...body.columnGroups ?? []].sort((left, right) => left.startIndex - right.startIndex);
4600
4556
  const ranges = [];
4601
4557
  let offset = startOffset;
4602
4558
  for (const columnGroup of columnGroups) {
@@ -4613,10 +4569,9 @@ function getRangesForOffsets(body, startOffset, endOffset) {
4613
4569
  return ranges;
4614
4570
  }
4615
4571
  function getRangesWithTables(body, startOffset, endOffset) {
4616
- var _body$tables;
4617
4572
  const ranges = [];
4618
4573
  let offset = startOffset;
4619
- for (const table of [...(_body$tables = body.tables) !== null && _body$tables !== void 0 ? _body$tables : []].sort((left, right) => left.startIndex - right.startIndex)) {
4574
+ for (const table of [...body.tables ?? []].sort((left, right) => left.startIndex - right.startIndex)) {
4620
4575
  const { startIndex, endIndex } = table;
4621
4576
  if (startIndex < startOffset || endIndex > endOffset) continue;
4622
4577
  if (offset !== startIndex) ranges.push(...getTextRangesByParagraphs(body, offset, startIndex - 1));
@@ -4627,9 +4582,8 @@ function getRangesWithTables(body, startOffset, endOffset) {
4627
4582
  return ranges;
4628
4583
  }
4629
4584
  function getTextRangesByParagraphs(body, startOffset, endOffset) {
4630
- var _body$paragraphs;
4631
4585
  if (startOffset > endOffset) return [];
4632
- const paragraphs = [...(_body$paragraphs = body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []].sort((left, right) => left.startIndex - right.startIndex);
4586
+ const paragraphs = [...body.paragraphs ?? []].sort((left, right) => left.startIndex - right.startIndex);
4633
4587
  const ranges = [];
4634
4588
  let offset = startOffset;
4635
4589
  for (const paragraph of paragraphs) {
@@ -4650,7 +4604,6 @@ function getTextRangesByParagraphs(body, startOffset, endOffset) {
4650
4604
  return ranges;
4651
4605
  }
4652
4606
  function getSelectAllScopes(body, activeRange) {
4653
- var _body$tables2, _body$customBlocks, _body$blockRanges, _body$columnGroups2;
4654
4607
  const scopes = [];
4655
4608
  const addScope = (scope) => {
4656
4609
  if ((scope === null || scope === void 0 ? void 0 : scope.length) && !scopes.some((existing) => isSameRanges(existing, scope))) scopes.push(scope);
@@ -4658,9 +4611,9 @@ function getSelectAllScopes(body, activeRange) {
4658
4611
  const startOffset = activeRange.startOffset;
4659
4612
  const endOffset = activeRange.endOffset;
4660
4613
  if (startOffset == null || endOffset == null) return [getWholeDocumentRanges(body)];
4661
- const table = ((_body$tables2 = body.tables) !== null && _body$tables2 !== void 0 ? _body$tables2 : []).find((item) => isRangeInside(startOffset, endOffset, item.startIndex, item.endIndex));
4662
- const customBlock = ((_body$customBlocks = body.customBlocks) !== null && _body$customBlocks !== void 0 ? _body$customBlocks : []).find((item) => item.startIndex >= startOffset && item.startIndex <= endOffset);
4663
- const blockRange = ((_body$blockRanges = body.blockRanges) !== null && _body$blockRanges !== void 0 ? _body$blockRanges : []).find((item) => isRangeInside(startOffset, endOffset, item.startIndex, item.endIndex));
4614
+ const table = (body.tables ?? []).find((item) => isRangeInside(startOffset, endOffset, item.startIndex, item.endIndex));
4615
+ const customBlock = (body.customBlocks ?? []).find((item) => item.startIndex >= startOffset && item.startIndex <= endOffset);
4616
+ const blockRange = (body.blockRanges ?? []).find((item) => isRangeInside(startOffset, endOffset, item.startIndex, item.endIndex));
4664
4617
  if (table) addScope([getTableRectRange(table)]);
4665
4618
  else if (customBlock) addScope([{
4666
4619
  endOffset: customBlock.startIndex,
@@ -4673,14 +4626,13 @@ function getSelectAllScopes(body, activeRange) {
4673
4626
  startOffset: blockRange.startIndex + 1
4674
4627
  }]);
4675
4628
  else {
4676
- var _body$tables3;
4677
- const paragraphRange = clampParagraphRangeByTables(getParagraphRangeAtOffset(body, startOffset), (_body$tables3 = body.tables) !== null && _body$tables3 !== void 0 ? _body$tables3 : [], startOffset);
4629
+ const paragraphRange = clampParagraphRangeByTables(getParagraphRangeAtOffset(body, startOffset), body.tables ?? [], startOffset);
4678
4630
  addScope(paragraphRange ? [{
4679
4631
  ...paragraphRange,
4680
4632
  rangeType: DOC_RANGE_TYPE.TEXT
4681
4633
  }] : null);
4682
4634
  }
4683
- const columnGroup = ((_body$columnGroups2 = body.columnGroups) !== null && _body$columnGroups2 !== void 0 ? _body$columnGroups2 : []).find((item) => isRangeInside(startOffset, endOffset, item.startIndex, item.endIndex));
4635
+ const columnGroup = (body.columnGroups ?? []).find((item) => isRangeInside(startOffset, endOffset, item.startIndex, item.endIndex));
4684
4636
  if (columnGroup) {
4685
4637
  const column = getColumnRanges(body, columnGroup).find((item) => isRangeInside(startOffset, endOffset, item.startOffset, item.endOffset));
4686
4638
  if (column) addScope(getRangesForOffsets(body, column.startOffset, column.endOffset));
@@ -4721,12 +4673,10 @@ function getTableRectRange(table) {
4721
4673
  };
4722
4674
  }
4723
4675
  function getParagraphRangeAtOffset(body, offset) {
4724
- var _body$paragraphs2;
4725
- const sortedParagraphs = [...(_body$paragraphs2 = body.paragraphs) !== null && _body$paragraphs2 !== void 0 ? _body$paragraphs2 : []].sort((left, right) => left.startIndex - right.startIndex);
4676
+ const sortedParagraphs = [...body.paragraphs ?? []].sort((left, right) => left.startIndex - right.startIndex);
4726
4677
  const paragraphStartOffsets = getParagraphContentStartOffsets(body);
4727
4678
  for (const paragraph of sortedParagraphs) {
4728
- var _paragraphStartOffset;
4729
- const startOffset = (_paragraphStartOffset = paragraphStartOffsets.get(paragraph.startIndex)) !== null && _paragraphStartOffset !== void 0 ? _paragraphStartOffset : 0;
4679
+ const startOffset = paragraphStartOffsets.get(paragraph.startIndex) ?? 0;
4730
4680
  if (startOffset <= offset && offset <= paragraph.startIndex) return {
4731
4681
  endOffset: paragraph.startIndex,
4732
4682
  startOffset
@@ -4756,8 +4706,7 @@ function isSameTextRangeCoverage(currentRanges, nextRanges) {
4756
4706
  return startOffset === targetRange.startOffset && endOffset === targetRange.endOffset && currentRanges.every((range) => range.startOffset >= targetRange.startOffset && range.endOffset <= targetRange.endOffset);
4757
4707
  }
4758
4708
  function getRangeType(range) {
4759
- var _range$rangeType;
4760
- return (_range$rangeType = range.rangeType) !== null && _range$rangeType !== void 0 ? _range$rangeType : DOC_RANGE_TYPE.TEXT;
4709
+ return range.rangeType ?? DOC_RANGE_TYPE.TEXT;
4761
4710
  }
4762
4711
 
4763
4712
  //#endregion
@@ -4829,7 +4778,7 @@ const IMEInputCommand = {
4829
4778
  id: "doc.command.ime-input",
4830
4779
  type: CommandType.COMMAND,
4831
4780
  handler: async (accessor, params) => {
4832
- var _renderManagerService, _docDataModel$getSelf, _body$customRanges, _body$customDecoratio;
4781
+ var _renderManagerService, _docDataModel$getSelf;
4833
4782
  const { unitId, newText, oldTextLen, isCompositionEnd, isCompositionStart } = params;
4834
4783
  const commandService = accessor.get(ICommandService);
4835
4784
  const renderManagerService = accessor.get(IRenderManagerService);
@@ -4862,9 +4811,9 @@ const IMEInputCommand = {
4862
4811
  };
4863
4812
  const defaultTextStyle = docMenuStyleService.getDefaultStyle();
4864
4813
  const styleCache = docMenuStyleService.getStyleCache();
4865
- const curCustomRange = getCustomRangeAtPosition((_body$customRanges = body.customRanges) !== null && _body$customRanges !== void 0 ? _body$customRanges : [], startOffset + oldTextLen, SHEET_EDITOR_UNITS.includes(unitId));
4814
+ const curCustomRange = getCustomRangeAtPosition(body.customRanges ?? [], startOffset + oldTextLen, SHEET_EDITOR_UNITS.includes(unitId));
4866
4815
  const curTextRun = getTextRunAtPosition(body, isCompositionStart ? endOffset : startOffset + oldTextLen, defaultTextStyle, styleCache, SHEET_EDITOR_UNITS.includes(unitId));
4867
- const customDecorations = getCustomDecorationAtPosition((_body$customDecoratio = body.customDecorations) !== null && _body$customDecoratio !== void 0 ? _body$customDecoratio : [], startOffset + oldTextLen);
4816
+ const customDecorations = getCustomDecorationAtPosition(body.customDecorations ?? [], startOffset + oldTextLen);
4868
4817
  const textX = new TextX();
4869
4818
  const jsonX = JSONX.getInstance();
4870
4819
  if (!previousActiveRange.collapsed && isCompositionStart) {
@@ -4920,7 +4869,7 @@ const IMEInputCommand = {
4920
4869
  function handleInlineFormat(preCommandId, params, commandService) {
4921
4870
  return commandService.executeCommand(SetInlineFormatCommand.id, {
4922
4871
  preCommandId,
4923
- ...params !== null && params !== void 0 ? params : {}
4872
+ ...params ?? {}
4924
4873
  });
4925
4874
  }
4926
4875
  const SetInlineFormatBoldCommandId = "doc.command.set-inline-format-bold";
@@ -5058,15 +5007,15 @@ const SetInlineFormatCommand = {
5058
5007
  id: "doc.command.set-inline-format",
5059
5008
  type: CommandType.COMMAND,
5060
5009
  handler: async (accessor, params) => {
5061
- var _docSelectionManagerS, _docRanges$find, _docDataModel$getSelf;
5010
+ var _docDataModel$getSelf;
5062
5011
  const { value, preCommandId } = params;
5063
5012
  const commandService = accessor.get(ICommandService);
5064
5013
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
5065
5014
  const univerInstanceService = accessor.get(IUniverInstanceService);
5066
5015
  const docMenuStyleService = accessor.get(DocMenuStyleService);
5067
- const textRanges = (_docSelectionManagerS = docSelectionManagerService.getTextRanges()) !== null && _docSelectionManagerS !== void 0 ? _docSelectionManagerS : [];
5016
+ const textRanges = docSelectionManagerService.getTextRanges() ?? [];
5068
5017
  const docRanges = textRanges.length > 0 ? textRanges.filter((range) => range.startOffset != null && range.endOffset != null) : docSelectionManagerService.getDocRanges();
5069
- const activeRange = (_docRanges$find = docRanges.find((r) => r.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
5018
+ const activeRange = docRanges.find((r) => r.isActive) ?? docRanges[0];
5070
5019
  if (docRanges.length === 0) return false;
5071
5020
  const { segmentId } = docRanges[0];
5072
5021
  const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
@@ -5115,7 +5064,6 @@ const SetInlineFormatCommand = {
5115
5064
  const memoryCursor = new MemoryCursor();
5116
5065
  memoryCursor.reset();
5117
5066
  for (const range of docRanges) {
5118
- var _formatPatch;
5119
5067
  let { startOffset, endOffset, rangeType } = range;
5120
5068
  if (startOffset == null || endOffset == null) continue;
5121
5069
  if (rangeType === DOC_RANGE_TYPE.RECT) startOffset = startOffset - 1;
@@ -5131,7 +5079,7 @@ const SetInlineFormatCommand = {
5131
5079
  textRuns: [{
5132
5080
  st: 0,
5133
5081
  ed: endOffset - startOffset,
5134
- ts: (_formatPatch = formatPatch) !== null && _formatPatch !== void 0 ? _formatPatch : { [COMMAND_ID_TO_FORMAT_KEY_MAP[preCommandId]]: formatValue }
5082
+ ts: formatPatch ?? { [COMMAND_ID_TO_FORMAT_KEY_MAP[preCommandId]]: formatValue }
5135
5083
  }]
5136
5084
  };
5137
5085
  const len = startOffset - memoryCursor.cursor;
@@ -5166,11 +5114,10 @@ function getReverseFormatValue(ts, key, preCommandId) {
5166
5114
  else return (ts === null || ts === void 0 ? void 0 : ts[key]) === BaselineOffset.SUPERSCRIPT ? BaselineOffset.NORMAL : BaselineOffset.SUPERSCRIPT;
5167
5115
  }
5168
5116
  function getStyleInTextRange(body, textRange, defaultStyle) {
5169
- var _textRuns$find$ts$ff, _textRuns$find, _textRuns$0$ts, _textRuns$0$ts2, _textRuns$find$ts$bg, _textRuns$find2, _textRuns$find$ts$cl, _textRuns$find3, _textRuns$find$ts$tex, _textRuns$find4;
5117
+ var _textRuns$find, _textRuns$0$ts, _textRuns$0$ts2, _textRuns$find2, _textRuns$find3, _textRuns$find4;
5170
5118
  const { startOffset, endOffset, collapsed } = textRange;
5171
5119
  if (collapsed) {
5172
- var _body$textRuns;
5173
- const textRuns = (_body$textRuns = body.textRuns) !== null && _body$textRuns !== void 0 ? _body$textRuns : [];
5120
+ const textRuns = body.textRuns ?? [];
5174
5121
  let textRun = null;
5175
5122
  for (let i = textRuns.length - 1; i >= 0; i--) {
5176
5123
  const curTextRun = textRuns[i];
@@ -5192,10 +5139,10 @@ function getStyleInTextRange(body, textRange, defaultStyle) {
5192
5139
  }).filter(Boolean);
5193
5140
  style.fs = style.fs ? Math.max(style.fs, ...fsArr) : fsArr.length ? Math.max(...fsArr) : void 0;
5194
5141
  style.fs = !style.fs || Number.isNaN(style.fs) ? void 0 : style.fs;
5195
- style.ff = (_textRuns$find$ts$ff = (_textRuns$find = textRuns.find((t) => {
5142
+ style.ff = ((_textRuns$find = textRuns.find((t) => {
5196
5143
  var _t$ts2;
5197
5144
  return ((_t$ts2 = t.ts) === null || _t$ts2 === void 0 ? void 0 : _t$ts2.ff) != null;
5198
- })) === null || _textRuns$find === void 0 || (_textRuns$find = _textRuns$find.ts) === null || _textRuns$find === void 0 ? void 0 : _textRuns$find.ff) !== null && _textRuns$find$ts$ff !== void 0 ? _textRuns$find$ts$ff : style.ff;
5145
+ })) === null || _textRuns$find === void 0 || (_textRuns$find = _textRuns$find.ts) === null || _textRuns$find === void 0 ? void 0 : _textRuns$find.ff) ?? style.ff;
5199
5146
  style.it = textRuns.length && textRuns.every((t) => {
5200
5147
  var _t$ts3;
5201
5148
  return ((_t$ts3 = t.ts) === null || _t$ts3 === void 0 ? void 0 : _t$ts3.it) === BooleanNumber.TRUE;
@@ -5212,18 +5159,18 @@ function getStyleInTextRange(body, textRange, defaultStyle) {
5212
5159
  var _t$ts6;
5213
5160
  return ((_t$ts6 = t.ts) === null || _t$ts6 === void 0 || (_t$ts6 = _t$ts6.st) === null || _t$ts6 === void 0 ? void 0 : _t$ts6.s) === BooleanNumber.TRUE;
5214
5161
  }) ? (_textRuns$0$ts2 = textRuns[0].ts) === null || _textRuns$0$ts2 === void 0 ? void 0 : _textRuns$0$ts2.st : style.st;
5215
- style.bg = (_textRuns$find$ts$bg = (_textRuns$find2 = textRuns.find((t) => {
5162
+ style.bg = ((_textRuns$find2 = textRuns.find((t) => {
5216
5163
  var _t$ts7;
5217
5164
  return ((_t$ts7 = t.ts) === null || _t$ts7 === void 0 ? void 0 : _t$ts7.bg) != null;
5218
- })) === null || _textRuns$find2 === void 0 || (_textRuns$find2 = _textRuns$find2.ts) === null || _textRuns$find2 === void 0 ? void 0 : _textRuns$find2.bg) !== null && _textRuns$find$ts$bg !== void 0 ? _textRuns$find$ts$bg : style.bg;
5219
- style.cl = (_textRuns$find$ts$cl = (_textRuns$find3 = textRuns.find((t) => {
5165
+ })) === null || _textRuns$find2 === void 0 || (_textRuns$find2 = _textRuns$find2.ts) === null || _textRuns$find2 === void 0 ? void 0 : _textRuns$find2.bg) ?? style.bg;
5166
+ style.cl = ((_textRuns$find3 = textRuns.find((t) => {
5220
5167
  var _t$ts8;
5221
5168
  return ((_t$ts8 = t.ts) === null || _t$ts8 === void 0 ? void 0 : _t$ts8.cl) != null;
5222
- })) === null || _textRuns$find3 === void 0 || (_textRuns$find3 = _textRuns$find3.ts) === null || _textRuns$find3 === void 0 ? void 0 : _textRuns$find3.cl) !== null && _textRuns$find$ts$cl !== void 0 ? _textRuns$find$ts$cl : style.cl;
5223
- style.textFill = (_textRuns$find$ts$tex = (_textRuns$find4 = textRuns.find((t) => {
5169
+ })) === null || _textRuns$find3 === void 0 || (_textRuns$find3 = _textRuns$find3.ts) === null || _textRuns$find3 === void 0 ? void 0 : _textRuns$find3.cl) ?? style.cl;
5170
+ style.textFill = ((_textRuns$find4 = textRuns.find((t) => {
5224
5171
  var _t$ts9;
5225
5172
  return ((_t$ts9 = t.ts) === null || _t$ts9 === void 0 ? void 0 : _t$ts9.textFill) != null;
5226
- })) === null || _textRuns$find4 === void 0 || (_textRuns$find4 = _textRuns$find4.ts) === null || _textRuns$find4 === void 0 ? void 0 : _textRuns$find4.textFill) !== null && _textRuns$find$ts$tex !== void 0 ? _textRuns$find$ts$tex : style.textFill;
5173
+ })) === null || _textRuns$find4 === void 0 || (_textRuns$find4 = _textRuns$find4.ts) === null || _textRuns$find4 === void 0 ? void 0 : _textRuns$find4.textFill) ?? style.textFill;
5227
5174
  const vas = textRuns.filter((t) => {
5228
5175
  var _t$ts10;
5229
5176
  return (t === null || t === void 0 || (_t$ts10 = t.ts) === null || _t$ts10 === void 0 ? void 0 : _t$ts10.va) != null;
@@ -5388,7 +5335,6 @@ const ReplaceSelectionCommand = {
5388
5335
  id: "doc.command.replace-selection",
5389
5336
  type: CommandType.COMMAND,
5390
5337
  handler(accessor, params) {
5391
- var _params$selection;
5392
5338
  if (!params) return false;
5393
5339
  const commandService = accessor.get(ICommandService);
5394
5340
  const { unitId, body: insertBody, textRanges } = params;
@@ -5396,7 +5342,7 @@ const ReplaceSelectionCommand = {
5396
5342
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
5397
5343
  if (!docDataModel) return false;
5398
5344
  const body = docDataModel.getBody();
5399
- const selection = (_params$selection = params.selection) !== null && _params$selection !== void 0 ? _params$selection : docSelectionManagerService.getActiveTextRange();
5345
+ const selection = params.selection ?? docSelectionManagerService.getActiveTextRange();
5400
5346
  if (!selection || !body) return false;
5401
5347
  const doMutation = {
5402
5348
  id: RichTextEditingMutation.id,
@@ -5490,18 +5436,18 @@ const ListOperationCommand = {
5490
5436
  id: "doc.command.list-operation",
5491
5437
  type: CommandType.COMMAND,
5492
5438
  handler: (accessor, params) => {
5493
- var _ref, _params$docRange, _segment$getBody$para, _segment$getBody, _segment$getBody$data, _segment$getBody2;
5439
+ var _segment$getBody, _segment$getBody2;
5494
5440
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
5495
5441
  const univerInstanceService = accessor.get(IUniverInstanceService);
5496
5442
  const commandService = accessor.get(ICommandService);
5497
5443
  const listType = params.listType;
5498
5444
  const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
5499
- const docRanges = (_ref = (_params$docRange = params.docRange) !== null && _params$docRange !== void 0 ? _params$docRange : docSelectionManagerService.getDocRanges()) !== null && _ref !== void 0 ? _ref : [];
5445
+ const docRanges = params.docRange ?? docSelectionManagerService.getDocRanges() ?? [];
5500
5446
  if (docDataModel == null || docRanges.length === 0) return false;
5501
5447
  const segmentId = docRanges[0].segmentId;
5502
5448
  const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
5503
- const paragraphs = (_segment$getBody$para = segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
5504
- const dataStream = (_segment$getBody$data = segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
5449
+ const paragraphs = (segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) ?? [];
5450
+ const dataStream = (segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) ?? "";
5505
5451
  if (!paragraphs.length) return false;
5506
5452
  const currentParagraphs = BuildTextUtils.range.getParagraphsInRanges(docRanges, paragraphs, dataStream);
5507
5453
  const unitId = docDataModel.getUnitId();
@@ -5532,18 +5478,18 @@ const ChangeListTypeCommand = {
5532
5478
  id: "doc.command.change-list-type",
5533
5479
  type: CommandType.COMMAND,
5534
5480
  handler: (accessor, params) => {
5535
- var _params$docRange2, _segment$getBody$para2, _segment$getBody3, _segment$getBody$data2, _segment$getBody4;
5481
+ var _segment$getBody3, _segment$getBody4;
5536
5482
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
5537
5483
  const univerInstanceService = accessor.get(IUniverInstanceService);
5538
5484
  const commandService = accessor.get(ICommandService);
5539
5485
  const { listType } = params;
5540
5486
  const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
5541
- const activeRanges = (_params$docRange2 = params.docRange) !== null && _params$docRange2 !== void 0 ? _params$docRange2 : docSelectionManagerService.getDocRanges();
5487
+ const activeRanges = params.docRange ?? docSelectionManagerService.getDocRanges();
5542
5488
  if (docDataModel == null || activeRanges == null || !activeRanges.length) return false;
5543
5489
  const { segmentId } = activeRanges[0];
5544
5490
  const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
5545
- const paragraphs = (_segment$getBody$para2 = segment === null || segment === void 0 || (_segment$getBody3 = segment.getBody()) === null || _segment$getBody3 === void 0 ? void 0 : _segment$getBody3.paragraphs) !== null && _segment$getBody$para2 !== void 0 ? _segment$getBody$para2 : [];
5546
- const dataStream = (_segment$getBody$data2 = segment === null || segment === void 0 || (_segment$getBody4 = segment.getBody()) === null || _segment$getBody4 === void 0 ? void 0 : _segment$getBody4.dataStream) !== null && _segment$getBody$data2 !== void 0 ? _segment$getBody$data2 : "";
5491
+ const paragraphs = (segment === null || segment === void 0 || (_segment$getBody3 = segment.getBody()) === null || _segment$getBody3 === void 0 ? void 0 : _segment$getBody3.paragraphs) ?? [];
5492
+ const dataStream = (segment === null || segment === void 0 || (_segment$getBody4 = segment.getBody()) === null || _segment$getBody4 === void 0 ? void 0 : _segment$getBody4.dataStream) ?? "";
5547
5493
  if (!paragraphs.length) return false;
5548
5494
  const currentParagraphs = BuildTextUtils.range.getParagraphsInRanges(activeRanges, paragraphs, dataStream);
5549
5495
  const unitId = docDataModel.getUnitId();
@@ -5579,7 +5525,7 @@ const ChangeListNestingLevelCommand = {
5579
5525
  id: "doc.command.change-list-nesting-level",
5580
5526
  type: CommandType.COMMAND,
5581
5527
  handler: (accessor, params) => {
5582
- var _docSelectionManagerS, _segment$getBody$para3, _segment$getBody5, _segment$getBody$data3, _segment$getBody6;
5528
+ var _segment$getBody5, _segment$getBody6;
5583
5529
  if (!params) return false;
5584
5530
  const { type } = params;
5585
5531
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
@@ -5589,10 +5535,10 @@ const ChangeListNestingLevelCommand = {
5589
5535
  const activeRange = docSelectionManagerService.getActiveTextRange();
5590
5536
  if (docDataModel == null || activeRange == null) return false;
5591
5537
  const { segmentId } = activeRange;
5592
- const selections = (_docSelectionManagerS = docSelectionManagerService.getDocRanges()) !== null && _docSelectionManagerS !== void 0 ? _docSelectionManagerS : [];
5538
+ const selections = docSelectionManagerService.getDocRanges() ?? [];
5593
5539
  const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
5594
- const paragraphs = (_segment$getBody$para3 = segment === null || segment === void 0 || (_segment$getBody5 = segment.getBody()) === null || _segment$getBody5 === void 0 ? void 0 : _segment$getBody5.paragraphs) !== null && _segment$getBody$para3 !== void 0 ? _segment$getBody$para3 : [];
5595
- const dataStream = (_segment$getBody$data3 = segment === null || segment === void 0 || (_segment$getBody6 = segment.getBody()) === null || _segment$getBody6 === void 0 ? void 0 : _segment$getBody6.dataStream) !== null && _segment$getBody$data3 !== void 0 ? _segment$getBody$data3 : "";
5540
+ const paragraphs = (segment === null || segment === void 0 || (_segment$getBody5 = segment.getBody()) === null || _segment$getBody5 === void 0 ? void 0 : _segment$getBody5.paragraphs) ?? [];
5541
+ const dataStream = (segment === null || segment === void 0 || (_segment$getBody6 = segment.getBody()) === null || _segment$getBody6 === void 0 ? void 0 : _segment$getBody6.dataStream) ?? "";
5596
5542
  if (!paragraphs.length) return false;
5597
5543
  const currentParagraphs = BuildTextUtils.range.getParagraphsInRange(activeRange, paragraphs, dataStream);
5598
5544
  const unitId = docDataModel.getUnitId();
@@ -5666,7 +5612,7 @@ const ToggleCheckListCommand = {
5666
5612
  params: {
5667
5613
  unitId,
5668
5614
  actions: [],
5669
- textRanges: textRanges !== null && textRanges !== void 0 ? textRanges : [],
5615
+ textRanges: textRanges ?? [],
5670
5616
  segmentId,
5671
5617
  isEditing: false
5672
5618
  }
@@ -5703,7 +5649,7 @@ const QuickListCommand = {
5703
5649
  id: "doc.command.quick-list",
5704
5650
  type: CommandType.COMMAND,
5705
5651
  handler(accessor, params) {
5706
- var _docDataModel$getBody, _docDataModel$getBody2, _paragraph$bullet;
5652
+ var _docDataModel$getBody;
5707
5653
  if (!params) return false;
5708
5654
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
5709
5655
  const univerInstanceService = accessor.get(IUniverInstanceService);
@@ -5719,7 +5665,7 @@ const QuickListCommand = {
5719
5665
  const { paragraphStyle = {} } = paragraph;
5720
5666
  const bulletParagraphTextStyle = (PRESET_LIST_TYPE[listType].nestingLevel[0].paragraphProperties || {}).textStyle;
5721
5667
  let listId = generateRandomId(6);
5722
- const paragraphs = (_docDataModel$getBody = (_docDataModel$getBody2 = docDataModel.getBody()) === null || _docDataModel$getBody2 === void 0 ? void 0 : _docDataModel$getBody2.paragraphs) !== null && _docDataModel$getBody !== void 0 ? _docDataModel$getBody : [];
5668
+ const paragraphs = ((_docDataModel$getBody = docDataModel.getBody()) === null || _docDataModel$getBody === void 0 ? void 0 : _docDataModel$getBody.paragraphs) ?? [];
5723
5669
  const curIndex = paragraphs.findIndex((i) => i.startIndex === paragraph.startIndex);
5724
5670
  const prevParagraph = paragraphs[curIndex - 1];
5725
5671
  const nextParagraph = paragraphs[curIndex + 1];
@@ -5767,7 +5713,7 @@ const QuickListCommand = {
5767
5713
  indentFirstLine: void 0
5768
5714
  },
5769
5715
  bullet: {
5770
- ...(_paragraph$bullet = paragraph.bullet) !== null && _paragraph$bullet !== void 0 ? _paragraph$bullet : {
5716
+ ...paragraph.bullet ?? {
5771
5717
  nestingLevel: 0,
5772
5718
  textStyle: { fs: 20 }
5773
5719
  },
@@ -5784,7 +5730,6 @@ const QuickListCommand = {
5784
5730
  }
5785
5731
  };
5786
5732
  function insertList(accessor, listType, trigger) {
5787
- var _contentInsertRange$s, _contentInsertRange$e, _sourceParagraph$para;
5788
5733
  const commandService = accessor.get(ICommandService);
5789
5734
  const docDataModel = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
5790
5735
  if (!docDataModel) return false;
@@ -5797,13 +5742,13 @@ function insertList(accessor, listType, trigger) {
5797
5742
  const paragraph = contentInsertRange ? null : getCurrentParagraph(accessor);
5798
5743
  if (!contentInsertRange && !paragraph) return false;
5799
5744
  const sourceParagraph = paragraph || void 0;
5800
- const insertOffset = (_contentInsertRange$s = contentInsertRange === null || contentInsertRange === void 0 ? void 0 : contentInsertRange.startOffset) !== null && _contentInsertRange$s !== void 0 ? _contentInsertRange$s : sourceParagraph.startIndex + 1;
5745
+ const insertOffset = (contentInsertRange === null || contentInsertRange === void 0 ? void 0 : contentInsertRange.startOffset) ?? sourceParagraph.startIndex + 1;
5801
5746
  const sourceBullet = sourceParagraph === null || sourceParagraph === void 0 ? void 0 : sourceParagraph.bullet;
5802
5747
  const textX = BuildTextUtils.selection.replace({
5803
5748
  doc: docDataModel,
5804
5749
  selection: {
5805
5750
  startOffset: insertOffset,
5806
- endOffset: (_contentInsertRange$e = contentInsertRange === null || contentInsertRange === void 0 ? void 0 : contentInsertRange.endOffset) !== null && _contentInsertRange$e !== void 0 ? _contentInsertRange$e : insertOffset,
5751
+ endOffset: (contentInsertRange === null || contentInsertRange === void 0 ? void 0 : contentInsertRange.endOffset) ?? insertOffset,
5807
5752
  collapsed: true
5808
5753
  },
5809
5754
  body: {
@@ -5811,7 +5756,7 @@ function insertList(accessor, listType, trigger) {
5811
5756
  paragraphs: [{
5812
5757
  startIndex: 0,
5813
5758
  paragraphId: createParagraphId(/* @__PURE__ */ new Set()),
5814
- paragraphStyle: { ...(_sourceParagraph$para = sourceParagraph === null || sourceParagraph === void 0 ? void 0 : sourceParagraph.paragraphStyle) !== null && _sourceParagraph$para !== void 0 ? _sourceParagraph$para : {} },
5759
+ paragraphStyle: { ...(sourceParagraph === null || sourceParagraph === void 0 ? void 0 : sourceParagraph.paragraphStyle) ?? {} },
5815
5760
  bullet: {
5816
5761
  listType,
5817
5762
  listId: (sourceBullet === null || sourceBullet === void 0 ? void 0 : sourceBullet.listType) === listType ? sourceBullet.listId : generateRandomId(6),
@@ -5869,7 +5814,7 @@ const AlignOperationCommand = {
5869
5814
  id: "doc.command.align-action",
5870
5815
  type: CommandType.COMMAND,
5871
5816
  handler: (accessor, params) => {
5872
- var _segment$getBody$para, _segment$getBody, _segment$getBody$data, _segment$getBody2;
5817
+ var _segment$getBody, _segment$getBody2;
5873
5818
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
5874
5819
  const univerInstanceService = accessor.get(IUniverInstanceService);
5875
5820
  const commandService = accessor.get(ICommandService);
@@ -5880,8 +5825,8 @@ const AlignOperationCommand = {
5880
5825
  if (allRanges.length === 0) return false;
5881
5826
  const segmentId = allRanges[0].segmentId;
5882
5827
  const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
5883
- const paragraphs = (_segment$getBody$para = segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
5884
- const dataStream = (_segment$getBody$data = segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
5828
+ const paragraphs = (segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) ?? [];
5829
+ const dataStream = (segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) ?? "";
5885
5830
  if (paragraphs == null) return false;
5886
5831
  const currentParagraphs = BuildTextUtils.range.getParagraphsInRanges(allRanges, paragraphs, dataStream);
5887
5832
  const unitId = docDataModel.getUnitId();
@@ -6021,7 +5966,6 @@ const SetParagraphNamedStyleCommand = {
6021
5966
  id: "doc.command.set-paragraph-named-style",
6022
5967
  type: CommandType.COMMAND,
6023
5968
  handler(accessor, params) {
6024
- var _params$textRanges;
6025
5969
  if (!params) return false;
6026
5970
  const doc = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
6027
5971
  if (!doc) return false;
@@ -6029,7 +5973,7 @@ const SetParagraphNamedStyleCommand = {
6029
5973
  const selectionService = accessor.get(DocSelectionManagerService);
6030
5974
  const contentInsertRange = params.textRanges ? null : consumeContentInsertRange(accessor, unitId);
6031
5975
  if (contentInsertRange) return insertNamedStyleParagraph(accessor, doc, params.value, contentInsertRange.startOffset, contentInsertRange.endOffset, contentInsertRange.segmentId);
6032
- const selections = (_params$textRanges = params.textRanges) !== null && _params$textRanges !== void 0 ? _params$textRanges : selectionService.getTextRanges({
5976
+ const selections = params.textRanges ?? selectionService.getTextRanges({
6033
5977
  unitId,
6034
5978
  subUnitId: unitId
6035
5979
  });
@@ -6110,7 +6054,7 @@ const QuickHeadingCommand = {
6110
6054
  id: "doc.command.quick-heading",
6111
6055
  type: CommandType.COMMAND,
6112
6056
  handler(accessor, params) {
6113
- var _segment$getBody$para, _segment$getBody, _segment$getBody$data, _segment$getBody2;
6057
+ var _segment$getBody, _segment$getBody2;
6114
6058
  if (!params) return false;
6115
6059
  const { value } = params;
6116
6060
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
@@ -6121,8 +6065,8 @@ const QuickHeadingCommand = {
6121
6065
  if (docDataModel == null || activeRange == null || !activeRange.collapsed) return false;
6122
6066
  const { segmentId, startOffset } = activeRange;
6123
6067
  const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
6124
- const paragraphs = (_segment$getBody$para = segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
6125
- const dataStream = (_segment$getBody$data = segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
6068
+ const paragraphs = (segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) ?? [];
6069
+ const dataStream = (segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) ?? "";
6126
6070
  const paragraph = BuildTextUtils.paragraph.util.getParagraphsInRange(activeRange, paragraphs, dataStream)[0];
6127
6071
  if (!paragraph) return false;
6128
6072
  const { paragraphStart } = paragraph;
@@ -6462,7 +6406,7 @@ var NodePositionConvertToCursor = class {
6462
6406
  const isStartBack = start.glyph === start_sp && isFirst ? start.isBack : true;
6463
6407
  const isEndBack = end.glyph === end_sp && isLast ? end.isBack : false;
6464
6408
  const collapsed = start === end;
6465
- const rawAnchorGlyph = isStartBack ? preGlyph !== null && preGlyph !== void 0 ? preGlyph : firstGlyph : firstGlyph;
6409
+ const rawAnchorGlyph = isStartBack ? preGlyph ?? firstGlyph : firstGlyph;
6466
6410
  const anchorGlyph = this._getCaretGlyph(rawAnchorGlyph, glyphGroup, start_sp);
6467
6411
  const selectedGlyphs = glyphGroup.slice(start_sp, end_sp + 1);
6468
6412
  const isSelectionOnlyNonInlineDrawing = !collapsed && selectedGlyphs.length > 0 && selectedGlyphs.every((glyph) => this._isNonInlineDrawingGlyph(glyph));
@@ -6513,10 +6457,8 @@ var NodePositionConvertToCursor = class {
6513
6457
  };
6514
6458
  }
6515
6459
  _getCaretGlyph(glyph, glyphGroup, glyphIndex) {
6516
- var _this$_findTextLikeGl;
6517
6460
  if (!glyph || !this._isNonInlineDrawingGlyph(glyph)) return glyph;
6518
- const neighbor = (_this$_findTextLikeGl = this._findTextLikeGlyph(glyphGroup, glyphIndex - 1, -1)) !== null && _this$_findTextLikeGl !== void 0 ? _this$_findTextLikeGl : this._findTextLikeGlyph(glyphGroup, glyphIndex + 1, 1);
6519
- return neighbor !== null && neighbor !== void 0 ? neighbor : {
6461
+ return this._findTextLikeGlyph(glyphGroup, glyphIndex - 1, -1) ?? this._findTextLikeGlyph(glyphGroup, glyphIndex + 1, 1) ?? {
6520
6462
  ...glyph,
6521
6463
  bBox: getDefaultCaretBoundingBox(glyph)
6522
6464
  };
@@ -6686,8 +6628,7 @@ var NodePositionConvertToCursor = class {
6686
6628
  this._liquid.translatePagePadding(tablePage);
6687
6629
  }
6688
6630
  if (hasHorizontalViewport) {
6689
- var _viewport$leadingInse;
6690
- const visibleLeft = this._liquid.x + tableLeft - ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0);
6631
+ const visibleLeft = this._liquid.x + tableLeft - (viewport.leadingInsetLeft ?? 0);
6691
6632
  this._horizontalClip = {
6692
6633
  left: visibleLeft,
6693
6634
  right: visibleLeft + viewport.viewportWidth
@@ -6705,11 +6646,13 @@ var NodePositionConvertToCursor = class {
6705
6646
  const section = sections[s];
6706
6647
  const columns = section.columns;
6707
6648
  const { start_next: start_c, end_next: end_c } = this._getSelectionRuler(NodePositionMap.section, startPosition, endPosition, columns.length - 1, s);
6649
+ this._liquid.translateSave();
6708
6650
  this._liquid.translateSection(section);
6709
6651
  for (let c = start_c; c <= end_c; c++) {
6710
6652
  const column = columns[c];
6711
6653
  const lines = column.lines;
6712
6654
  const { start_next: start_l, end_next: end_l } = this._getSelectionRuler(NodePositionMap.column, startPosition, endPosition, lines.length - 1, c);
6655
+ this._liquid.translateSave();
6713
6656
  this._liquid.translateColumn(column);
6714
6657
  for (let l = start_l; l <= end_l; l++) {
6715
6658
  const line = lines[l];
@@ -6732,7 +6675,9 @@ var NodePositionConvertToCursor = class {
6732
6675
  }
6733
6676
  this._liquid.translateRestore();
6734
6677
  }
6678
+ this._liquid.translateRestore();
6735
6679
  }
6680
+ this._liquid.translateRestore();
6736
6681
  }
6737
6682
  this._liquid.translateRestore();
6738
6683
  this._horizontalClip = previousHorizontalClip;
@@ -6741,8 +6686,7 @@ var NodePositionConvertToCursor = class {
6741
6686
  }
6742
6687
  };
6743
6688
  function hasHorizontalTableViewport$2(viewport) {
6744
- var _viewport$leadingInse2, _viewport$trailingIns;
6745
- return viewport != null && ((_viewport$leadingInse2 = viewport.leadingInsetLeft) !== null && _viewport$leadingInse2 !== void 0 ? _viewport$leadingInse2 : 0) + viewport.contentWidth + ((_viewport$trailingIns = viewport.trailingInsetRight) !== null && _viewport$trailingIns !== void 0 ? _viewport$trailingIns : 0) > viewport.viewportWidth;
6689
+ return viewport != null && (viewport.leadingInsetLeft ?? 0) + viewport.contentWidth + (viewport.trailingInsetRight ?? 0) > viewport.viewportWidth;
6746
6690
  }
6747
6691
  function clipPositionToHorizontalRange(position, clip) {
6748
6692
  if (!clip) return position;
@@ -6787,14 +6731,14 @@ function getDefaultCaretBoundingBox(glyph) {
6787
6731
  };
6788
6732
  }
6789
6733
  function getGlyphFontSize(glyph) {
6790
- var _ref, _glyph$fontStyle$orig, _glyph$fontStyle, _glyph$fontStyle2, _glyph$ts;
6791
- const fontSize = (_ref = (_glyph$fontStyle$orig = (_glyph$fontStyle = glyph.fontStyle) === null || _glyph$fontStyle === void 0 ? void 0 : _glyph$fontStyle.originFontSize) !== null && _glyph$fontStyle$orig !== void 0 ? _glyph$fontStyle$orig : (_glyph$fontStyle2 = glyph.fontStyle) === null || _glyph$fontStyle2 === void 0 ? void 0 : _glyph$fontStyle2.fontSize) !== null && _ref !== void 0 ? _ref : (_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.fs;
6734
+ var _glyph$fontStyle, _glyph$fontStyle2, _glyph$ts;
6735
+ const fontSize = ((_glyph$fontStyle = glyph.fontStyle) === null || _glyph$fontStyle === void 0 ? void 0 : _glyph$fontStyle.originFontSize) ?? ((_glyph$fontStyle2 = glyph.fontStyle) === null || _glyph$fontStyle2 === void 0 ? void 0 : _glyph$fontStyle2.fontSize) ?? ((_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.fs);
6792
6736
  return typeof fontSize === "number" && Number.isFinite(fontSize) && fontSize > 0 ? fontSize : 14;
6793
6737
  }
6794
6738
  function getDocumentUnitId$1(docSkeleton) {
6795
- var _viewModel$getDataMod, _viewModel$getDataMod2, _viewModel$getDataMod3, _viewModel$getDataMod4;
6739
+ var _viewModel$getDataMod, _viewModel$getDataMod2, _viewModel$getDataMod3;
6796
6740
  const viewModel = docSkeleton.getViewModel();
6797
- return (_viewModel$getDataMod = (_viewModel$getDataMod2 = viewModel.getDataModel) === null || _viewModel$getDataMod2 === void 0 || (_viewModel$getDataMod4 = (_viewModel$getDataMod3 = _viewModel$getDataMod2.call(viewModel)).getUnitId) === null || _viewModel$getDataMod4 === void 0 ? void 0 : _viewModel$getDataMod4.call(_viewModel$getDataMod3)) !== null && _viewModel$getDataMod !== void 0 ? _viewModel$getDataMod : "";
6741
+ return ((_viewModel$getDataMod = viewModel.getDataModel) === null || _viewModel$getDataMod === void 0 || (_viewModel$getDataMod3 = (_viewModel$getDataMod2 = _viewModel$getDataMod.call(viewModel)).getUnitId) === null || _viewModel$getDataMod3 === void 0 ? void 0 : _viewModel$getDataMod3.call(_viewModel$getDataMod2)) ?? "";
6798
6742
  }
6799
6743
 
6800
6744
  //#endregion
@@ -6884,8 +6828,8 @@ function getColumnBoundary(table, column) {
6884
6828
  var _table$tableSource;
6885
6829
  const columns = (_table$tableSource = table.tableSource) === null || _table$tableSource === void 0 ? void 0 : _table$tableSource.tableColumns;
6886
6830
  if (columns && column >= 0 && column <= columns.length) return columns.slice(0, column).reduce((total, tableColumn) => {
6887
- var _tableColumn$size$wid, _tableColumn$size;
6888
- return total + ((_tableColumn$size$wid = (_tableColumn$size = tableColumn.size) === null || _tableColumn$size === void 0 || (_tableColumn$size = _tableColumn$size.width) === null || _tableColumn$size === void 0 ? void 0 : _tableColumn$size.v) !== null && _tableColumn$size$wid !== void 0 ? _tableColumn$size$wid : 0);
6831
+ var _tableColumn$size;
6832
+ return total + (((_tableColumn$size = tableColumn.size) === null || _tableColumn$size === void 0 || (_tableColumn$size = _tableColumn$size.width) === null || _tableColumn$size === void 0 ? void 0 : _tableColumn$size.v) ?? 0);
6889
6833
  }, 0);
6890
6834
  const row = table.rows[0];
6891
6835
  const cell = row === null || row === void 0 ? void 0 : row.cells[column];
@@ -6895,15 +6839,14 @@ function getColumnBoundary(table, column) {
6895
6839
  return null;
6896
6840
  }
6897
6841
  function getDocumentUnitId(docSkeleton) {
6898
- var _viewModel$getDataMod, _viewModel$getDataMod2, _viewModel$getDataMod3, _viewModel$getDataMod4;
6842
+ var _viewModel$getDataMod, _viewModel$getDataMod2, _viewModel$getDataMod3;
6899
6843
  const viewModel = docSkeleton.getViewModel();
6900
- return (_viewModel$getDataMod = (_viewModel$getDataMod2 = viewModel.getDataModel) === null || _viewModel$getDataMod2 === void 0 || (_viewModel$getDataMod4 = (_viewModel$getDataMod3 = _viewModel$getDataMod2.call(viewModel)).getUnitId) === null || _viewModel$getDataMod4 === void 0 ? void 0 : _viewModel$getDataMod4.call(_viewModel$getDataMod3)) !== null && _viewModel$getDataMod !== void 0 ? _viewModel$getDataMod : "";
6844
+ return ((_viewModel$getDataMod = viewModel.getDataModel) === null || _viewModel$getDataMod === void 0 || (_viewModel$getDataMod3 = (_viewModel$getDataMod2 = _viewModel$getDataMod.call(viewModel)).getUnitId) === null || _viewModel$getDataMod3 === void 0 ? void 0 : _viewModel$getDataMod3.call(_viewModel$getDataMod2)) ?? "";
6901
6845
  }
6902
6846
  function pushViewportClippedPoints(pointGroup, position, viewport, tableLeft) {
6903
- var _viewport$leadingInse;
6904
6847
  const scrollLeft = hasHorizontalTableViewport$1(viewport) ? viewport.scrollLeft : 0;
6905
6848
  const viewportWidth = hasHorizontalTableViewport$1(viewport) ? viewport.viewportWidth : null;
6906
- const visibleLeft = tableLeft - ((_viewport$leadingInse = viewport === null || viewport === void 0 ? void 0 : viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0);
6849
+ const visibleLeft = tableLeft - ((viewport === null || viewport === void 0 ? void 0 : viewport.leadingInsetLeft) ?? 0);
6907
6850
  const startX = position.startX - scrollLeft;
6908
6851
  const endX = position.endX - scrollLeft;
6909
6852
  const clippedStartX = viewportWidth == null ? startX : Math.max(startX, visibleLeft);
@@ -6916,8 +6859,7 @@ function pushViewportClippedPoints(pointGroup, position, viewport, tableLeft) {
6916
6859
  }));
6917
6860
  }
6918
6861
  function hasHorizontalTableViewport$1(viewport) {
6919
- var _viewport$leadingInse2, _viewport$trailingIns;
6920
- return viewport != null && ((_viewport$leadingInse2 = viewport.leadingInsetLeft) !== null && _viewport$leadingInse2 !== void 0 ? _viewport$leadingInse2 : 0) + viewport.contentWidth + ((_viewport$trailingIns = viewport.trailingInsetRight) !== null && _viewport$trailingIns !== void 0 ? _viewport$trailingIns : 0) > viewport.viewportWidth;
6862
+ return viewport != null && (viewport.leadingInsetLeft ?? 0) + viewport.contentWidth + (viewport.trailingInsetRight ?? 0) > viewport.viewportWidth;
6921
6863
  }
6922
6864
  var NodePositionConvertToRectRange = class {
6923
6865
  constructor(_documentOffsetConfig, _docSkeleton) {
@@ -6926,7 +6868,6 @@ var NodePositionConvertToRectRange = class {
6926
6868
  _defineProperty(this, "_liquid", new Liquid());
6927
6869
  }
6928
6870
  getRangePointData(startNodePosition, endNodePosition) {
6929
- var _this$_documentOffset, _this$_documentOffset2;
6930
6871
  const pointGroup = [];
6931
6872
  const docSkeleton = this._docSkeleton;
6932
6873
  const skeletonData = docSkeleton.getSkeletonData();
@@ -6941,8 +6882,8 @@ var NodePositionConvertToRectRange = class {
6941
6882
  const unitId = getDocumentUnitId(docSkeleton);
6942
6883
  const sourceTableId = getTableIdAndSliceIndex(tableId).tableId;
6943
6884
  const nestedTableContexts = documentSkeletonTableIterator(pages, {
6944
- docsLeft: (_this$_documentOffset = this._documentOffsetConfig.docsLeft) !== null && _this$_documentOffset !== void 0 ? _this$_documentOffset : 0,
6945
- docsTop: (_this$_documentOffset2 = this._documentOffsetConfig.docsTop) !== null && _this$_documentOffset2 !== void 0 ? _this$_documentOffset2 : 0,
6885
+ docsLeft: this._documentOffsetConfig.docsLeft ?? 0,
6886
+ docsTop: this._documentOffsetConfig.docsTop ?? 0,
6946
6887
  pageMarginTop,
6947
6888
  skeFooters: skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.skeFooters,
6948
6889
  skeHeaders: skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.skeHeaders,
@@ -6963,11 +6904,10 @@ var NodePositionConvertToRectRange = class {
6963
6904
  if (table == null) {
6964
6905
  const nestedTableContext = nestedTableContexts.find((context) => context.pageIndex === p && (context.source === "column" || context.source === "header" || context.source === "footer") && context.tableId.startsWith(tableId));
6965
6906
  if (nestedTableContext) {
6966
- var _this$_documentOffset3, _this$_documentOffset4;
6967
6907
  const nestedTable = nestedTableContext.table;
6968
6908
  const viewport = getDocsTableRenderViewport(unitId, sourceTableId);
6969
- const nestedX = nestedTableContext.tableRect.left - nestedTable.left - ((_this$_documentOffset3 = this._documentOffsetConfig.docsLeft) !== null && _this$_documentOffset3 !== void 0 ? _this$_documentOffset3 : 0);
6970
- const nestedY = nestedTableContext.tableRect.top - ((_this$_documentOffset4 = this._documentOffsetConfig.docsTop) !== null && _this$_documentOffset4 !== void 0 ? _this$_documentOffset4 : 0);
6909
+ const nestedX = nestedTableContext.tableRect.left - nestedTable.left - (this._documentOffsetConfig.docsLeft ?? 0);
6910
+ const nestedY = nestedTableContext.tableRect.top - (this._documentOffsetConfig.docsTop ?? 0);
6971
6911
  if (intersectsMergedCell) {
6972
6912
  const rows = nestedTable.rows.filter((row) => row.index >= startRow && row.index <= endRow);
6973
6913
  const firstRow = rows[0];
@@ -7133,9 +7073,8 @@ function expandRangeByMergedCells(table, range) {
7133
7073
  changed = false;
7134
7074
  table.tableRows.forEach((row, rowIndex) => {
7135
7075
  row.tableCells.forEach((cell, columnIndex) => {
7136
- var _cell$rowSpan, _cell$columnSpan;
7137
- const rowSpan = (_cell$rowSpan = cell.rowSpan) !== null && _cell$rowSpan !== void 0 ? _cell$rowSpan : 1;
7138
- const columnSpan = (_cell$columnSpan = cell.columnSpan) !== null && _cell$columnSpan !== void 0 ? _cell$columnSpan : 1;
7076
+ const rowSpan = cell.rowSpan ?? 1;
7077
+ const columnSpan = cell.columnSpan ?? 1;
7139
7078
  if (rowSpan <= 0 || columnSpan <= 0 || rowSpan === 1 && columnSpan === 1) return;
7140
7079
  const mergedRange = {
7141
7080
  startRowIndex: rowIndex,
@@ -7163,9 +7102,8 @@ function rangeIntersectsMergedCell(table, range) {
7163
7102
  if (!table) return false;
7164
7103
  const normalized = normalizeRange(range);
7165
7104
  return table.tableRows.some((row, rowIndex) => row.tableCells.some((cell, columnIndex) => {
7166
- var _cell$rowSpan2, _cell$columnSpan2;
7167
- const rowSpan = (_cell$rowSpan2 = cell.rowSpan) !== null && _cell$rowSpan2 !== void 0 ? _cell$rowSpan2 : 1;
7168
- const columnSpan = (_cell$columnSpan2 = cell.columnSpan) !== null && _cell$columnSpan2 !== void 0 ? _cell$columnSpan2 : 1;
7105
+ const rowSpan = cell.rowSpan ?? 1;
7106
+ const columnSpan = cell.columnSpan ?? 1;
7169
7107
  if (rowSpan <= 0 || columnSpan <= 0 || rowSpan === 1 && columnSpan === 1) return false;
7170
7108
  return rangesIntersect(normalized, {
7171
7109
  startRowIndex: rowIndex,
@@ -7295,16 +7233,16 @@ var TextRange = class {
7295
7233
  }, 1e3);
7296
7234
  }
7297
7235
  get startOffset() {
7298
- var _getOneTextSelectionR, _this$_docSkeleton$ge;
7299
- const { startOffset } = (_getOneTextSelectionR = getOneTextSelectionRange(this._cursorList)) !== null && _getOneTextSelectionR !== void 0 ? _getOneTextSelectionR : {};
7236
+ var _this$_docSkeleton$ge;
7237
+ const { startOffset } = getOneTextSelectionRange(this._cursorList) ?? {};
7300
7238
  const body = (_this$_docSkeleton$ge = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId)) === null || _this$_docSkeleton$ge === void 0 ? void 0 : _this$_docSkeleton$ge.getBody();
7301
7239
  if (startOffset == null || body == null) return startOffset;
7302
7240
  const maxLength = body.dataStream.length - 2;
7303
7241
  return Math.min(maxLength, startOffset);
7304
7242
  }
7305
7243
  get endOffset() {
7306
- var _getOneTextSelectionR2, _this$_docSkeleton$ge2;
7307
- const { endOffset } = (_getOneTextSelectionR2 = getOneTextSelectionRange(this._cursorList)) !== null && _getOneTextSelectionR2 !== void 0 ? _getOneTextSelectionR2 : {};
7244
+ var _this$_docSkeleton$ge2;
7245
+ const { endOffset } = getOneTextSelectionRange(this._cursorList) ?? {};
7308
7246
  const body = (_this$_docSkeleton$ge2 = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId)) === null || _this$_docSkeleton$ge2 === void 0 ? void 0 : _this$_docSkeleton$ge2.getBody();
7309
7247
  if (endOffset == null || body == null) return endOffset;
7310
7248
  const maxLength = body.dataStream.length - 2;
@@ -7511,7 +7449,7 @@ function convertPositionsToRectRanges(scene, document, docSkeleton, anchorNodePo
7511
7449
  const nodePositionGroup = new NodePositionConvertToRectRange(document.getOffsetConfig(), docSkeleton).getNodePositionGroup(anchorNodePosition, focusNodePosition);
7512
7450
  const ranges = [];
7513
7451
  try {
7514
- for (const position of nodePositionGroup !== null && nodePositionGroup !== void 0 ? nodePositionGroup : []) ranges.push(new RectRange(scene, document, docSkeleton, position.anchor, position.focus, style, segmentId, segmentPage));
7452
+ for (const position of nodePositionGroup ?? []) ranges.push(new RectRange(scene, document, docSkeleton, position.anchor, position.focus, style, segmentId, segmentPage));
7515
7453
  return ranges;
7516
7454
  } catch (error) {
7517
7455
  ranges.forEach((range) => range.dispose());
@@ -7691,11 +7629,11 @@ function getDescendantTables(node) {
7691
7629
  return node.children.flatMap(getDescendantTables);
7692
7630
  }
7693
7631
  function isInSameColumnPage(anchorPosition, focusPosition) {
7694
- var _anchorPosition$path$, _anchorPosition$path, _focusPosition$path$i, _focusPosition$path;
7632
+ var _anchorPosition$path, _focusPosition$path;
7695
7633
  const anchorColumnInfo = getDocumentSkeletonColumnPagePathInfo(anchorPosition);
7696
7634
  const focusColumnInfo = getDocumentSkeletonColumnPagePathInfo(focusPosition);
7697
- const anchorPageIndex = (_anchorPosition$path$ = (_anchorPosition$path = anchorPosition.path) === null || _anchorPosition$path === void 0 ? void 0 : _anchorPosition$path.indexOf("page")) !== null && _anchorPosition$path$ !== void 0 ? _anchorPosition$path$ : -1;
7698
- const focusPageIndex = (_focusPosition$path$i = (_focusPosition$path = focusPosition.path) === null || _focusPosition$path === void 0 ? void 0 : _focusPosition$path.indexOf("page")) !== null && _focusPosition$path$i !== void 0 ? _focusPosition$path$i : -1;
7635
+ const anchorPageIndex = ((_anchorPosition$path = anchorPosition.path) === null || _anchorPosition$path === void 0 ? void 0 : _anchorPosition$path.indexOf("page")) ?? -1;
7636
+ const focusPageIndex = ((_focusPosition$path = focusPosition.path) === null || _focusPosition$path === void 0 ? void 0 : _focusPosition$path.indexOf("page")) ?? -1;
7699
7637
  return anchorPageIndex >= 0 && focusPageIndex >= 0 && anchorPageIndex === anchorPosition.path.length - 1 && focusPageIndex === focusPosition.path.length - 1 && !!anchorColumnInfo && !!focusColumnInfo && anchorColumnInfo.pageIndex === focusColumnInfo.pageIndex && anchorColumnInfo.columnGroupId === focusColumnInfo.columnGroupId && anchorColumnInfo.columnIndex === focusColumnInfo.columnIndex;
7700
7638
  }
7701
7639
  function getColumnInputBoundaryCollapsedPosition(anchorPosition, focusPosition, skeleton) {
@@ -7783,14 +7721,8 @@ function getRangeListFromSelection(anchorPosition, focusPosition, scene, documen
7783
7721
  const startOffset = Math.min(anchorOffset, focusOffset);
7784
7722
  const endOffset = Math.max(anchorOffset, focusOffset);
7785
7723
  const originRange = compareNodePosition(anchorPosition, focusPosition);
7786
- const findStartNodePositionByCharIndex = (charIndex, isBack = true) => {
7787
- var _skeleton$findNodePos;
7788
- return (_skeleton$findNodePos = skeleton.findNodePositionByCharIndex(charIndex, isBack, segmentId, segmentPage)) !== null && _skeleton$findNodePos !== void 0 ? _skeleton$findNodePos : charIndex === startOffset ? originRange.start : void 0;
7789
- };
7790
- const findEndNodePositionByCharIndex = (charIndex, isBack = true) => {
7791
- var _skeleton$findNodePos2;
7792
- return (_skeleton$findNodePos2 = skeleton.findNodePositionByCharIndex(charIndex, isBack, segmentId, segmentPage)) !== null && _skeleton$findNodePos2 !== void 0 ? _skeleton$findNodePos2 : charIndex === endOffset ? originRange.end : void 0;
7793
- };
7724
+ const findStartNodePositionByCharIndex = (charIndex, isBack = true) => skeleton.findNodePositionByCharIndex(charIndex, isBack, segmentId, segmentPage) ?? (charIndex === startOffset ? originRange.start : void 0);
7725
+ const findEndNodePositionByCharIndex = (charIndex, isBack = true) => skeleton.findNodePositionByCharIndex(charIndex, isBack, segmentId, segmentPage) ?? (charIndex === endOffset ? originRange.end : void 0);
7794
7726
  const appendTextRange = (rangeStart, rangeEnd, endIsBack = true) => {
7795
7727
  if (rangeStart > rangeEnd) return true;
7796
7728
  const sp = findStartNodePositionByCharIndex(rangeStart, true);
@@ -8054,9 +7986,8 @@ function getNextWordBoundaryOffset(content, nodeIndex, paragraphStartOffset, dir
8054
7986
  return paragraphStartOffset;
8055
7987
  }
8056
7988
  if (direction === Direction.RIGHT) {
8057
- var _target$end;
8058
7989
  const target = ranges.find((range) => range.end > nodeIndex);
8059
- return paragraphStartOffset + ((_target$end = target === null || target === void 0 ? void 0 : target.end) !== null && _target$end !== void 0 ? _target$end : content.length);
7990
+ return paragraphStartOffset + ((target === null || target === void 0 ? void 0 : target.end) ?? content.length);
8060
7991
  }
8061
7992
  return null;
8062
7993
  }
@@ -8188,9 +8119,8 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
8188
8119
  this._addRectRanges(rectRanges);
8189
8120
  };
8190
8121
  for (const range of ranges) {
8191
- var _range$style;
8192
8122
  const { startOffset, endOffset, rangeType, startNodePosition, endNodePosition } = range;
8193
- const rangeStyle = (_range$style = range.style) !== null && _range$style !== void 0 ? _range$style : style;
8123
+ const rangeStyle = range.style ?? style;
8194
8124
  if (rangeType !== DOC_RANGE_TYPE.RECT && startOffset === endOffset) {
8195
8125
  const textRange = cursorConvertToTextRange(scene, {
8196
8126
  ...range,
@@ -8429,7 +8359,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
8429
8359
  strokeWidth: 1,
8430
8360
  stroke: "rgba(0, 0, 0, 0)",
8431
8361
  strokeActive: "rgba(0, 0, 0, 1)",
8432
- fill: `rgba(${r}, ${g}, ${b}, ${a !== null && a !== void 0 ? a : .3})`
8362
+ fill: `rgba(${r}, ${g}, ${b}, ${a ?? .3})`
8433
8363
  };
8434
8364
  this._setRangeStyle(style);
8435
8365
  }
@@ -8515,8 +8445,8 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
8515
8445
  if (this._container.parentElement !== document.body) document.body.appendChild(this._container);
8516
8446
  }
8517
8447
  _getOwnerDocument() {
8518
- var _this$_container$owne, _this$_container;
8519
- return (_this$_container$owne = (_this$_container = this._container) === null || _this$_container === void 0 ? void 0 : _this$_container.ownerDocument) !== null && _this$_container$owne !== void 0 ? _this$_container$owne : document;
8448
+ var _this$_container;
8449
+ return ((_this$_container = this._container) === null || _this$_container === void 0 ? void 0 : _this$_container.ownerDocument) ?? document;
8520
8450
  }
8521
8451
  _getNodePosition(node) {
8522
8452
  if (node == null) return;
@@ -8886,14 +8816,14 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
8886
8816
  return this._getElementEmbedOwner(element) === currentEmbedOwner && this._containsCurrentLayoutElement(element);
8887
8817
  }
8888
8818
  _getCurrentEmbedOwner() {
8889
- var _this$_layoutService, _ref, _this$_getElementEmbe;
8819
+ var _this$_layoutService;
8890
8820
  const rootContainerElement = (_this$_layoutService = this._layoutService) === null || _this$_layoutService === void 0 ? void 0 : _this$_layoutService.rootContainerElement;
8891
- return (_ref = (_this$_getElementEmbe = this._getElementEmbedOwner(this._input)) !== null && _this$_getElementEmbe !== void 0 ? _this$_getElementEmbe : this._getElementEmbedOwner(this._container)) !== null && _ref !== void 0 ? _ref : this._getElementEmbedOwner(rootContainerElement instanceof HTMLElement ? rootContainerElement : void 0);
8821
+ return this._getElementEmbedOwner(this._input) ?? this._getElementEmbedOwner(this._container) ?? this._getElementEmbedOwner(rootContainerElement instanceof HTMLElement ? rootContainerElement : void 0);
8892
8822
  }
8893
8823
  _getElementEmbedOwner(element) {
8894
- var _element$closest$getA, _element$closest;
8824
+ var _element$closest;
8895
8825
  if (!element || typeof element.closest !== "function") return;
8896
- return (_element$closest$getA = (_element$closest = element.closest(`[${"data-embed-interaction-boundary-owner"}]`)) === null || _element$closest === void 0 ? void 0 : _element$closest.getAttribute("data-embed-interaction-boundary-owner")) !== null && _element$closest$getA !== void 0 ? _element$closest$getA : void 0;
8826
+ return ((_element$closest = element.closest(`[${"data-embed-interaction-boundary-owner"}]`)) === null || _element$closest === void 0 ? void 0 : _element$closest.getAttribute("data-embed-interaction-boundary-owner")) ?? void 0;
8897
8827
  }
8898
8828
  _containsOwnEditorElement(element) {
8899
8829
  var _this$_container2, _this$_inputParent;
@@ -8972,9 +8902,8 @@ const SwitchDocModeCommand = {
8972
8902
  if (action) rawActions.push(action);
8973
8903
  else return false;
8974
8904
  if (oldDocumentFlavor !== DocumentFlavor.MODERN) {
8975
- var _body$customBlocks;
8976
8905
  const { drawings = {}, body } = docDataModel.getSnapshot();
8977
- const customBlocks = (_body$customBlocks = body === null || body === void 0 ? void 0 : body.customBlocks) !== null && _body$customBlocks !== void 0 ? _body$customBlocks : [];
8906
+ const customBlocks = (body === null || body === void 0 ? void 0 : body.customBlocks) ?? [];
8978
8907
  for (const drawingId in drawings) {
8979
8908
  var _glyph$parent, _column$parent;
8980
8909
  const drawing = drawings[drawingId];
@@ -8997,7 +8926,7 @@ const SwitchDocModeCommand = {
8997
8926
  const newPositionV = {
8998
8927
  ...drawingPositionV,
8999
8928
  relativeFrom: ObjectRelativeFromV.PARAGRAPH,
9000
- posOffset: (prevPosOffset !== null && prevPosOffset !== void 0 ? prevPosOffset : 0) - delta
8929
+ posOffset: (prevPosOffset ?? 0) - delta
9001
8930
  };
9002
8931
  const updateDrawingAction = jsonX.replaceOp([
9003
8932
  "drawings",
@@ -9020,9 +8949,8 @@ const SwitchDocModeCommand = {
9020
8949
  //#region src/commands/commands/table/doc-table-create.command.ts
9021
8950
  const CreateDocTableCommandId = "doc.command.create-table";
9022
8951
  function buildDocTableInsertBody(params) {
9023
- var _params$existingParag;
9024
8952
  const { tableDataStream, tableParagraphs, sectionBreaks, tableId, textRun } = params;
9025
- const existingParagraphIds = (_params$existingParag = params.existingParagraphIds) !== null && _params$existingParag !== void 0 ? _params$existingParag : new Set(tableParagraphs.map((paragraph) => paragraph.paragraphId));
8953
+ const existingParagraphIds = params.existingParagraphIds ?? new Set(tableParagraphs.map((paragraph) => paragraph.paragraphId));
9026
8954
  const dataStream = `${tableDataStream}${DataStreamTreeTokenType.PARAGRAPH}`;
9027
8955
  const tableEnd = tableDataStream.length;
9028
8956
  return {
@@ -9069,7 +8997,7 @@ const CreateDocTableCommand = {
9069
8997
  id: CreateDocTableCommandId,
9070
8998
  type: CommandType.COMMAND,
9071
8999
  handler: async (accessor, params) => {
9072
- var _ref, _contentInsertRange$s, _docDataModel$getSelf, _contentInsertRange$s2, _body$paragraphs, _curGlyph$parent, _body$paragraphs2;
9000
+ var _docDataModel$getSelf, _curGlyph$parent, _body$paragraphs;
9073
9001
  const { rowCount, colCount } = params;
9074
9002
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
9075
9003
  const univerInstanceService = accessor.get(IUniverInstanceService);
@@ -9085,7 +9013,7 @@ const CreateDocTableCommand = {
9085
9013
  }
9086
9014
  const activeRange = docSelectionManagerService.getActiveTextRange();
9087
9015
  if (activeRange == null && contentInsertRange == null) return false;
9088
- const segmentId = (_ref = (_contentInsertRange$s = contentInsertRange === null || contentInsertRange === void 0 ? void 0 : contentInsertRange.segmentId) !== null && _contentInsertRange$s !== void 0 ? _contentInsertRange$s : activeRange === null || activeRange === void 0 ? void 0 : activeRange.segmentId) !== null && _ref !== void 0 ? _ref : "";
9016
+ const segmentId = (contentInsertRange === null || contentInsertRange === void 0 ? void 0 : contentInsertRange.segmentId) ?? (activeRange === null || activeRange === void 0 ? void 0 : activeRange.segmentId) ?? "";
9089
9017
  const segmentPage = activeRange === null || activeRange === void 0 ? void 0 : activeRange.segmentPage;
9090
9018
  const body = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
9091
9019
  if (body == null) return false;
@@ -9093,9 +9021,9 @@ const CreateDocTableCommand = {
9093
9021
  const docSkeletonManagerService = getCommandSkeleton(accessor, unitId);
9094
9022
  const skeleton = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getSkeleton();
9095
9023
  if (skeleton == null) return false;
9096
- const startOffset = normalizeTableInsertOffset(body, (_contentInsertRange$s2 = contentInsertRange === null || contentInsertRange === void 0 ? void 0 : contentInsertRange.startOffset) !== null && _contentInsertRange$s2 !== void 0 ? _contentInsertRange$s2 : activeRange.startOffset);
9024
+ const startOffset = normalizeTableInsertOffset(body, (contentInsertRange === null || contentInsertRange === void 0 ? void 0 : contentInsertRange.startOffset) ?? activeRange.startOffset);
9097
9025
  if (!canInsertTableAtOffset(body, startOffset)) return false;
9098
- const prevParagraph = ((_body$paragraphs = body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).find((paragraph) => {
9026
+ const prevParagraph = (body.paragraphs ?? []).find((paragraph) => {
9099
9027
  return getParagraphContentStartOffset(body, paragraph) < startOffset && startOffset <= paragraph.startIndex;
9100
9028
  });
9101
9029
  const curGlyph = skeleton.findNodeByCharIndex(startOffset, segmentId, segmentPage);
@@ -9142,7 +9070,7 @@ const CreateDocTableCommand = {
9142
9070
  sectionBreaks,
9143
9071
  tableId: tableSource.tableId,
9144
9072
  textRun: curTextRun,
9145
- existingParagraphIds: new Set((_body$paragraphs2 = body.paragraphs) === null || _body$paragraphs2 === void 0 ? void 0 : _body$paragraphs2.map((paragraph) => paragraph.paragraphId))
9073
+ existingParagraphIds: new Set((_body$paragraphs = body.paragraphs) === null || _body$paragraphs === void 0 ? void 0 : _body$paragraphs.map((paragraph) => paragraph.paragraphId))
9146
9074
  });
9147
9075
  textX.push({
9148
9076
  t: TextXActionType.INSERT,
@@ -9312,13 +9240,13 @@ const DocTableDeleteTableCommand = {
9312
9240
  id: "doc.table.delete-table",
9313
9241
  type: CommandType.COMMAND,
9314
9242
  handler: async (accessor, params) => {
9315
- var _params$targetRange, _docDataModel$getSelf3;
9243
+ var _docDataModel$getSelf3;
9316
9244
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
9317
9245
  const univerInstanceService = accessor.get(IUniverInstanceService);
9318
9246
  const commandService = accessor.get(ICommandService);
9319
9247
  const activeRectRanges = docSelectionManagerService.getRectRanges();
9320
9248
  const activeTextRange = docSelectionManagerService.getActiveTextRange();
9321
- const rangeInfo = getRangeInfoFromRanges((_params$targetRange = params === null || params === void 0 ? void 0 : params.targetRange) !== null && _params$targetRange !== void 0 ? _params$targetRange : activeTextRange, (params === null || params === void 0 ? void 0 : params.targetRange) ? [] : activeRectRanges);
9249
+ const rangeInfo = getRangeInfoFromRanges((params === null || params === void 0 ? void 0 : params.targetRange) ?? activeTextRange, (params === null || params === void 0 ? void 0 : params.targetRange) ? [] : activeRectRanges);
9322
9250
  if (rangeInfo == null) return false;
9323
9251
  const { segmentId } = rangeInfo;
9324
9252
  const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
@@ -9480,7 +9408,7 @@ const DocTableInsertColumnCommand = {
9480
9408
  id: DocTableInsertColumnCommandId,
9481
9409
  type: CommandType.COMMAND,
9482
9410
  handler: async (accessor, params) => {
9483
- var _docDataModel$getSelf2, _snapshot$tableSource, _documentStyle$pageSi, _documentStyle$pageSi2;
9411
+ var _docDataModel$getSelf2, _snapshot$tableSource, _documentStyle$pageSi;
9484
9412
  const { position } = params;
9485
9413
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
9486
9414
  const univerInstanceService = accessor.get(IUniverInstanceService);
@@ -9547,7 +9475,7 @@ const DocTableInsertColumnCommand = {
9547
9475
  const { marginLeft = 0, marginRight = 0 } = documentStyle;
9548
9476
  const tableColumns = snapshot === null || snapshot === void 0 || (_snapshot$tableSource = snapshot.tableSource) === null || _snapshot$tableSource === void 0 || (_snapshot$tableSource = _snapshot$tableSource[tableId]) === null || _snapshot$tableSource === void 0 ? void 0 : _snapshot$tableSource.tableColumns;
9549
9477
  if (!tableColumns) return false;
9550
- const pageWidth = ((_documentStyle$pageSi = (_documentStyle$pageSi2 = documentStyle.pageSize) === null || _documentStyle$pageSi2 === void 0 ? void 0 : _documentStyle$pageSi2.width) !== null && _documentStyle$pageSi !== void 0 ? _documentStyle$pageSi : 800) - marginLeft - marginRight;
9478
+ const pageWidth = (((_documentStyle$pageSi = documentStyle.pageSize) === null || _documentStyle$pageSi === void 0 ? void 0 : _documentStyle$pageSi.width) ?? 800) - marginLeft - marginRight;
9551
9479
  const tableWidth = tableColumns.reduce((sum, column) => sum + column.size.width.v, 0);
9552
9480
  const { newColWidth, widths } = getColumnWidths(tableWidth > 0 ? tableWidth : pageWidth, tableColumns, columnIndex);
9553
9481
  for (let i = 0; i < widths.length; i++) {
@@ -9584,14 +9512,13 @@ const DocTableTabCommand = {
9584
9512
  id: "doc.table.tab-in-table",
9585
9513
  type: CommandType.COMMAND,
9586
9514
  handler: async (accessor, params) => {
9587
- var _docRanges$find;
9588
9515
  const { shift } = params;
9589
9516
  const textSelectionManager = accessor.get(DocSelectionManagerService);
9590
9517
  const docRanges = textSelectionManager.getDocRanges();
9591
9518
  const commandService = accessor.get(ICommandService);
9592
9519
  const docDataModel = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
9593
9520
  if (!docDataModel) return false;
9594
- const activeRange = (_docRanges$find = docRanges.find((range) => range.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
9521
+ const activeRange = docRanges.find((range) => range.isActive) ?? docRanges[0];
9595
9522
  const docSkeletonManagerService = getCommandSkeleton(accessor, docDataModel.getUnitId());
9596
9523
  const skeleton = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getSkeleton();
9597
9524
  const viewModel = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getViewModel().getSelfOrHeaderFooterViewModel(activeRange === null || activeRange === void 0 ? void 0 : activeRange.segmentId);
@@ -9724,15 +9651,14 @@ const DOC_TRADITIONAL_WORKSPACE_BACKGROUND_COLOR = "#fafafa";
9724
9651
  const DOC_MODERN_WORKSPACE_BACKGROUND_COLOR = "#fff";
9725
9652
  const DOC_EDITOR_INTERNAL_BACKGROUND_COLOR = "transparent";
9726
9653
  function resolveDocRenderBackground(options) {
9727
- var _canvasColorService$g;
9728
9654
  const { documentFlavor, canvasColorService, editorBackgroundColor, isEditor } = options;
9729
- const backgroundColor = editorBackgroundColor !== null && editorBackgroundColor !== void 0 ? editorBackgroundColor : getDefaultDocCanvasBackgroundColor(documentFlavor, isEditor);
9655
+ const backgroundColor = editorBackgroundColor ?? getDefaultDocCanvasBackgroundColor(documentFlavor, isEditor);
9730
9656
  if (isEditor) return {
9731
9657
  canvasElementBackgroundColor: backgroundColor,
9732
9658
  docBackgroundFillColor: DOC_EDITOR_INTERNAL_BACKGROUND_COLOR
9733
9659
  };
9734
9660
  return {
9735
- canvasElementBackgroundColor: (_canvasColorService$g = canvasColorService === null || canvasColorService === void 0 ? void 0 : canvasColorService.getRenderColor(backgroundColor)) !== null && _canvasColorService$g !== void 0 ? _canvasColorService$g : backgroundColor,
9661
+ canvasElementBackgroundColor: (canvasColorService === null || canvasColorService === void 0 ? void 0 : canvasColorService.getRenderColor(backgroundColor)) ?? backgroundColor,
9736
9662
  docBackgroundFillColor: void 0
9737
9663
  };
9738
9664
  }
@@ -9849,8 +9775,8 @@ var Editor = class extends Disposable {
9849
9775
  return this._docSelectionManagerService.getDocRanges(params);
9850
9776
  }
9851
9777
  getCursorPosition() {
9852
- var _selectionRanges$find, _selectionRanges$find2;
9853
- return (_selectionRanges$find = (_selectionRanges$find2 = this.getSelectionRanges().find((range) => range.collapsed)) === null || _selectionRanges$find2 === void 0 ? void 0 : _selectionRanges$find2.startOffset) !== null && _selectionRanges$find !== void 0 ? _selectionRanges$find : -1;
9778
+ var _selectionRanges$find;
9779
+ return ((_selectionRanges$find = this.getSelectionRanges().find((range) => range.collapsed)) === null || _selectionRanges$find === void 0 ? void 0 : _selectionRanges$find.startOffset) ?? -1;
9854
9780
  }
9855
9781
  getEditorId() {
9856
9782
  return this._getEditorId();
@@ -9904,9 +9830,8 @@ var Editor = class extends Disposable {
9904
9830
  return this._param.cancelDefaultResizeListener;
9905
9831
  }
9906
9832
  getRenderConfig() {
9907
- var _this$_param$canvasSt;
9908
9833
  return {
9909
- canvasStyle: (_this$_param$canvasSt = this._param.canvasStyle) !== null && _this$_param$canvasSt !== void 0 ? _this$_param$canvasSt : {},
9834
+ canvasStyle: this._param.canvasStyle ?? {},
9910
9835
  scrollBar: this._param.scrollBar,
9911
9836
  ...this._param.backScrollOffset === void 0 ? {} : { backScrollOffset: this._param.backScrollOffset }
9912
9837
  };
@@ -10006,14 +9931,14 @@ let EditorService = class EditorService extends Disposable {
10006
9931
  this._blur$.next(null);
10007
9932
  }
10008
9933
  focus(editorUnitId) {
10009
- var _editor$getDocumentDa, _editor$getDocumentDa2;
9934
+ var _editor$getDocumentDa;
10010
9935
  if (editorUnitId === this._focusEditorUnitId) return;
10011
9936
  if (this._focusEditorUnitId) this.blur();
10012
9937
  if (editorUnitId == null) return;
10013
9938
  const editor = this.getEditor(editorUnitId);
10014
9939
  if (editor == null) return;
10015
9940
  this._univerInstanceService.setCurrentUnitForType(editorUnitId);
10016
- 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;
9941
+ const valueCount = (((_editor$getDocumentDa = editor.getDocumentData().body) === null || _editor$getDocumentDa === void 0 ? void 0 : _editor$getDocumentDa.dataStream) ?? "").replace(/\r?\n/g, "").length;
10017
9942
  this._contextService.setContextValue(EDITOR_ACTIVATED, true);
10018
9943
  if (!isInternalEditorID(editorUnitId)) this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, true);
10019
9944
  if (isCommentEditorID(editorUnitId)) this._contextService.setContextValue(FOCUSING_COMMENT_EDITOR, true);
@@ -10036,9 +9961,8 @@ let EditorService = class EditorService extends Disposable {
10036
9961
  return this._editors;
10037
9962
  }
10038
9963
  getEditorRenderConfig(editorUnitId) {
10039
- var _ref, _this$_editorRenderCo;
10040
9964
  const editor = this._editors.get(editorUnitId);
10041
- 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;
9965
+ return this._editorRenderConfigs.get(editorUnitId) ?? (editor === null || editor === void 0 ? void 0 : editor.getRenderConfig()) ?? null;
10042
9966
  }
10043
9967
  register(config, container) {
10044
9968
  const { initialSnapshot, canvasStyle = {} } = config;
@@ -10046,7 +9970,8 @@ let EditorService = class EditorService extends Disposable {
10046
9970
  this._editorRenderConfigs.set(editorUnitId, {
10047
9971
  canvasStyle,
10048
9972
  scrollBar: config.scrollBar,
10049
- ...config.backScrollOffset === void 0 ? {} : { backScrollOffset: config.backScrollOffset }
9973
+ ...config.backScrollOffset === void 0 ? {} : { backScrollOffset: config.backScrollOffset },
9974
+ ...config.preserveHostFocus === void 0 ? {} : { preserveHostFocus: config.preserveHostFocus }
10050
9975
  });
10051
9976
  if (this._univerInstanceService.getUnit(editorUnitId, UniverInstanceType.UNIVER_DOC) == null) this._univerInstanceService.createUnit(UniverInstanceType.UNIVER_DOC, initialSnapshot || this._getBlank(editorUnitId), { makeCurrent: false });
10052
9977
  let render = this._renderManagerService.getRenderUnitById(editorUnitId);
@@ -10162,7 +10087,6 @@ let DocBackScrollRenderController = class DocBackScrollRenderController extends
10162
10087
  anchorNodePosition && this.scrollToNode(anchorNodePosition);
10163
10088
  }
10164
10089
  scrollToNode(startNodePosition) {
10165
- var _editorRenderConfig$b;
10166
10090
  const { unitId, scene, mainComponent } = this._context;
10167
10091
  const skeleton = this._docSkeletonManagerService.getSkeleton();
10168
10092
  if (mainComponent == null || skeleton == null) return;
@@ -10178,7 +10102,7 @@ let DocBackScrollRenderController = class DocBackScrollRenderController extends
10178
10102
  let offsetY = 0;
10179
10103
  let offsetX = 0;
10180
10104
  const editorRenderConfig = this._editorService.getEditorRenderConfig(unitId);
10181
- const delta = editorRenderConfig ? (_editorRenderConfig$b = editorRenderConfig.backScrollOffset) !== null && _editorRenderConfig$b !== void 0 ? _editorRenderConfig$b : 0 : 100;
10105
+ const delta = editorRenderConfig ? editorRenderConfig.backScrollOffset ?? 0 : 100;
10182
10106
  if (top < boundTop) offsetY = top - boundTop - delta;
10183
10107
  else if (top > boundBottom - height) offsetY = top - boundBottom + height + delta;
10184
10108
  if (left < boundLeft) offsetX = left - boundLeft;
@@ -10224,11 +10148,11 @@ let DocParagraphPlaceholderRenderController = class DocParagraphPlaceholderRende
10224
10148
  this.disposeWithMe(documents.pageRender$.subscribe((pageRenderConfig) => this._drawPagePlaceholders(pageRenderConfig)));
10225
10149
  }
10226
10150
  _drawPagePlaceholders({ page, pageLeft, pageTop, ctx }) {
10227
- var _this$_context$unit$g, _activeRange$segmentI, _page$segmentId, _this$_context$mainCo;
10151
+ var _this$_context$unit$g, _this$_context$mainCo;
10228
10152
  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();
10229
10153
  if (!body) return;
10230
10154
  const activeRange = this._docSelectionManagerService.getActiveTextRange();
10231
- 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;
10155
+ if (!activeRange || (activeRange.segmentId ?? "") !== (page.segmentId ?? "")) return;
10232
10156
  const placeholders = getParagraphPlaceholderLayouts(page, body, this._getLocale(), pageLeft, pageTop, activeRange.startOffset, {
10233
10157
  docsLeft: (_this$_context$mainCo = this._context.mainComponent) === null || _this$_context$mainCo === void 0 ? void 0 : _this$_context$mainCo.getOffsetConfig().docsLeft,
10234
10158
  unitId: this._context.unitId
@@ -10260,20 +10184,19 @@ function shouldRenderParagraphPlaceholder(documentModel, unitId, config) {
10260
10184
  return ((_documentModel$getSna = documentModel.getSnapshot().documentStyle) === null || _documentModel$getSna === void 0 ? void 0 : _documentModel$getSna.documentFlavor) === DocumentFlavor.MODERN;
10261
10185
  }
10262
10186
  function getParagraphPlaceholderLayouts(page, body, locale, pageLeft = 0, pageTop = 0, activeOffset, options) {
10263
- var _body$paragraphs, _page$skeTables;
10264
- const paragraphs = new Map(((_body$paragraphs = body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).map((paragraph) => [paragraph.startIndex, paragraph]));
10187
+ var _page$skeTables;
10188
+ const paragraphs = new Map((body.paragraphs ?? []).map((paragraph) => [paragraph.startIndex, paragraph]));
10265
10189
  const layouts = [];
10266
10190
  const visitSection = (section, originLeft, originTop, clip) => {
10267
10191
  for (const column of section.columns) visitColumn(column, body, paragraphs, locale, layouts, originLeft + column.left, originTop + section.top, activeOffset, clip);
10268
10192
  };
10269
10193
  for (const section of page.sections) visitSection(section, pageLeft + page.marginLeft, pageTop + page.marginTop);
10270
10194
  (_page$skeTables = page.skeTables) === null || _page$skeTables === void 0 || _page$skeTables.forEach((table, tableId) => {
10271
- var _table$tableId, _options$unitId, _viewport$leadingInse, _viewport$trailingIns, _viewport$leadingInse2;
10272
- const sourceTableId = getTableIdAndSliceIndex((_table$tableId = table.tableId) !== null && _table$tableId !== void 0 ? _table$tableId : tableId).tableId;
10273
- const viewport = getDocsTableRenderViewport((_options$unitId = options === null || options === void 0 ? void 0 : options.unitId) !== null && _options$unitId !== void 0 ? _options$unitId : "", sourceTableId);
10274
- 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;
10195
+ const sourceTableId = getTableIdAndSliceIndex(table.tableId ?? tableId).tableId;
10196
+ const viewport = getDocsTableRenderViewport((options === null || options === void 0 ? void 0 : options.unitId) ?? "", sourceTableId);
10197
+ const hasHorizontalViewport = viewport != null && (viewport.leadingInsetLeft ?? 0) + viewport.contentWidth + (viewport.trailingInsetRight ?? 0) > viewport.viewportWidth;
10275
10198
  const tableLeft = pageLeft + page.marginLeft + table.left;
10276
- const tableViewportLeft = hasHorizontalViewport ? 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;
10199
+ const tableViewportLeft = hasHorizontalViewport ? getDocsTableViewportLeft(viewport, tableLeft - (viewport.leadingInsetLeft ?? 0), options === null || options === void 0 ? void 0 : options.docsLeft) : tableLeft;
10277
10200
  const tableViewportRight = tableViewportLeft + (hasHorizontalViewport ? viewport.viewportWidth : table.width);
10278
10201
  const tableScrollLeft = hasHorizontalViewport ? viewport.scrollLeft : 0;
10279
10202
  for (const row of table.rows) for (const cell of row.cells) {
@@ -10320,19 +10243,19 @@ function getPlaceholderText(paragraph, locale) {
10320
10243
  }
10321
10244
  }
10322
10245
  function getLinePlaceholderLayout(line, paragraph, text, originLeft, originTop, clip) {
10323
- var _divide$glyphGroup, _paragraph$paragraphS2, _paragraph$paragraphS3, _getLineFontFamily, _divide$left, _divide$paddingLeft, _ref, _divide$width, _clip$left, _clip$right;
10246
+ var _paragraph$paragraphS2;
10324
10247
  const divide = line.divides[0];
10325
- const firstGlyph = ((_divide$glyphGroup = divide === null || divide === void 0 ? void 0 : divide.glyphGroup) !== null && _divide$glyphGroup !== void 0 ? _divide$glyphGroup : [])[0];
10326
- const textStyle = 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 : NamedStyleType.NORMAL_TEXT];
10248
+ const firstGlyph = ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup) ?? [])[0];
10249
+ const textStyle = NAMED_STYLE_MAP[((_paragraph$paragraphS2 = paragraph.paragraphStyle) === null || _paragraph$paragraphS2 === void 0 ? void 0 : _paragraph$paragraphS2.namedStyleType) ?? NamedStyleType.NORMAL_TEXT];
10327
10250
  const fontSize = getPlaceholderFontSize(line, paragraph);
10328
- const fontFamily = (_getLineFontFamily = getLineFontFamily(line)) !== null && _getLineFontFamily !== void 0 ? _getLineFontFamily : DEFAULT_PLACEHOLDER_FONT_FAMILY;
10251
+ const fontFamily = getLineFontFamily(line) ?? DEFAULT_PLACEHOLDER_FONT_FAMILY;
10329
10252
  const fontWeight = (textStyle === null || textStyle === void 0 ? void 0 : textStyle.bl) ? "bold" : "normal";
10330
- 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);
10253
+ const lineStartX = originLeft + ((divide === null || divide === void 0 ? void 0 : divide.left) ?? 0) + ((divide === null || divide === void 0 ? void 0 : divide.paddingLeft) ?? 0);
10331
10254
  const listOffset = paragraph.bullet && firstGlyph ? firstGlyph.left + firstGlyph.width + LIST_PLACEHOLDER_GAP : 0;
10332
10255
  const x = lineStartX + listOffset;
10333
- 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);
10334
- const clipLeft = Math.max(x, (_clip$left = clip === null || clip === void 0 ? void 0 : clip.left) !== null && _clip$left !== void 0 ? _clip$left : x);
10335
- 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);
10256
+ const naturalMaxWidth = Math.max(0, ((divide === null || divide === void 0 ? void 0 : divide.width) ?? line.width ?? 0) - listOffset);
10257
+ const clipLeft = Math.max(x, (clip === null || clip === void 0 ? void 0 : clip.left) ?? x);
10258
+ const clipRight = Math.min(x + naturalMaxWidth, (clip === null || clip === void 0 ? void 0 : clip.right) ?? x + naturalMaxWidth);
10336
10259
  const clipTop = originTop + line.top;
10337
10260
  return {
10338
10261
  clipBottom: clipTop + line.lineHeight,
@@ -10349,32 +10272,31 @@ function getLinePlaceholderLayout(line, paragraph, text, originLeft, originTop,
10349
10272
  };
10350
10273
  }
10351
10274
  function isEmptyParagraph(dataStream, paragraphStart, paragraphEnd) {
10352
- var _dataStream$slice;
10353
- return stripNonTextTokens((_dataStream$slice = dataStream === null || dataStream === void 0 ? void 0 : dataStream.slice(paragraphStart, paragraphEnd)) !== null && _dataStream$slice !== void 0 ? _dataStream$slice : "").trim() === "";
10275
+ return stripNonTextTokens((dataStream === null || dataStream === void 0 ? void 0 : dataStream.slice(paragraphStart, paragraphEnd)) ?? "").trim() === "";
10354
10276
  }
10355
10277
  function stripNonTextTokens(text) {
10356
10278
  return text.replaceAll(DataStreamTreeTokenType.PARAGRAPH, "").replaceAll(DataStreamTreeTokenType.SECTION_BREAK, "").replaceAll(DataStreamTreeTokenType.DOCS_END, "");
10357
10279
  }
10358
10280
  function getLineFontSize(line) {
10359
10281
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) {
10360
- var _ref2, _glyph$fontStyle$orig, _glyph$fontStyle, _glyph$fontStyle2, _glyph$ts;
10361
- const fontSize = (_ref2 = (_glyph$fontStyle$orig = (_glyph$fontStyle = glyph.fontStyle) === null || _glyph$fontStyle === void 0 ? void 0 : _glyph$fontStyle.originFontSize) !== null && _glyph$fontStyle$orig !== void 0 ? _glyph$fontStyle$orig : (_glyph$fontStyle2 = glyph.fontStyle) === null || _glyph$fontStyle2 === void 0 ? void 0 : _glyph$fontStyle2.fontSize) !== null && _ref2 !== void 0 ? _ref2 : (_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.fs;
10282
+ var _glyph$fontStyle, _glyph$fontStyle2, _glyph$ts;
10283
+ const fontSize = ((_glyph$fontStyle = glyph.fontStyle) === null || _glyph$fontStyle === void 0 ? void 0 : _glyph$fontStyle.originFontSize) ?? ((_glyph$fontStyle2 = glyph.fontStyle) === null || _glyph$fontStyle2 === void 0 ? void 0 : _glyph$fontStyle2.fontSize) ?? ((_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.fs);
10362
10284
  if (fontSize) return fontSize;
10363
10285
  }
10364
10286
  return null;
10365
10287
  }
10366
10288
  function getPlaceholderFontSize(line, paragraph) {
10367
- var _paragraph$paragraphS4, _paragraph$paragraphS5, _ref3, _getLineFontSize;
10368
- const namedStyleType = (_paragraph$paragraphS4 = (_paragraph$paragraphS5 = paragraph.paragraphStyle) === null || _paragraph$paragraphS5 === void 0 ? void 0 : _paragraph$paragraphS5.namedStyleType) !== null && _paragraph$paragraphS4 !== void 0 ? _paragraph$paragraphS4 : NamedStyleType.NORMAL_TEXT;
10289
+ var _paragraph$paragraphS3;
10290
+ const namedStyleType = ((_paragraph$paragraphS3 = paragraph.paragraphStyle) === null || _paragraph$paragraphS3 === void 0 ? void 0 : _paragraph$paragraphS3.namedStyleType) ?? NamedStyleType.NORMAL_TEXT;
10369
10291
  const textStyle = NAMED_STYLE_MAP[namedStyleType];
10370
- const fontSize = (_ref3 = (_getLineFontSize = getLineFontSize(line)) !== null && _getLineFontSize !== void 0 ? _getLineFontSize : textStyle === null || textStyle === void 0 ? void 0 : textStyle.fs) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_PLACEHOLDER_FONT_SIZE;
10292
+ const fontSize = getLineFontSize(line) ?? (textStyle === null || textStyle === void 0 ? void 0 : textStyle.fs) ?? DEFAULT_PLACEHOLDER_FONT_SIZE;
10371
10293
  if (namedStyleType !== NamedStyleType.NORMAL_TEXT) return fontSize;
10372
10294
  return Math.max(fontSize, MIN_BODY_TEXT_PLACEHOLDER_FONT_SIZE);
10373
10295
  }
10374
10296
  function getLineFontFamily(line) {
10375
10297
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) {
10376
- var _glyph$fontStyle$font, _glyph$fontStyle3, _glyph$ts2;
10377
- const fontFamily = (_glyph$fontStyle$font = (_glyph$fontStyle3 = glyph.fontStyle) === null || _glyph$fontStyle3 === void 0 ? void 0 : _glyph$fontStyle3.fontFamily) !== null && _glyph$fontStyle$font !== void 0 ? _glyph$fontStyle$font : (_glyph$ts2 = glyph.ts) === null || _glyph$ts2 === void 0 ? void 0 : _glyph$ts2.ff;
10298
+ var _glyph$fontStyle3, _glyph$ts2;
10299
+ const fontFamily = ((_glyph$fontStyle3 = glyph.fontStyle) === null || _glyph$fontStyle3 === void 0 ? void 0 : _glyph$fontStyle3.fontFamily) ?? ((_glyph$ts2 = glyph.ts) === null || _glyph$ts2 === void 0 ? void 0 : _glyph$ts2.ff);
10378
10300
  if (fontFamily) return fontFamily;
10379
10301
  }
10380
10302
  return null;
@@ -10384,11 +10306,10 @@ function drawParagraphPlaceholders(ctx, placeholders) {
10384
10306
  ctx.fillStyle = PLACEHOLDER_COLOR;
10385
10307
  ctx.textBaseline = "alphabetic";
10386
10308
  for (const placeholder of placeholders) {
10387
- var _placeholder$clipLeft, _placeholder$clipRigh, _placeholder$clipTop, _placeholder$clipBott;
10388
- const clipLeft = (_placeholder$clipLeft = placeholder.clipLeft) !== null && _placeholder$clipLeft !== void 0 ? _placeholder$clipLeft : placeholder.x;
10389
- const clipRight = (_placeholder$clipRigh = placeholder.clipRight) !== null && _placeholder$clipRigh !== void 0 ? _placeholder$clipRigh : placeholder.x + placeholder.maxWidth;
10390
- const clipTop = (_placeholder$clipTop = placeholder.clipTop) !== null && _placeholder$clipTop !== void 0 ? _placeholder$clipTop : placeholder.y - placeholder.fontSize;
10391
- const clipBottom = (_placeholder$clipBott = placeholder.clipBottom) !== null && _placeholder$clipBott !== void 0 ? _placeholder$clipBott : placeholder.y + placeholder.fontSize;
10309
+ const clipLeft = placeholder.clipLeft ?? placeholder.x;
10310
+ const clipRight = placeholder.clipRight ?? placeholder.x + placeholder.maxWidth;
10311
+ const clipTop = placeholder.clipTop ?? placeholder.y - placeholder.fontSize;
10312
+ const clipBottom = placeholder.clipBottom ?? placeholder.y + placeholder.fontSize;
10392
10313
  if (clipRight <= clipLeft || clipBottom <= clipTop) continue;
10393
10314
  ctx.save();
10394
10315
  ctx.beginPath();
@@ -10433,13 +10354,12 @@ function resolveDocFitPaddingX(availableWidth, paddingX) {
10433
10354
  return 0;
10434
10355
  }
10435
10356
  function calcDocFitToWidthScale(params) {
10436
- var _options$maxScale;
10437
10357
  const options = normalizeDocFitToWidthOptions(params.options);
10438
10358
  if (options.mode !== "fit-width") return 1;
10439
10359
  if (!Number.isFinite(params.availableWidth) || !Number.isFinite(params.baseWidth) || params.baseWidth <= 0) return 1;
10440
10360
  const paddingX = resolveDocFitPaddingX(params.availableWidth, options.paddingX);
10441
10361
  const rawScale = Math.max(0, params.availableWidth - paddingX * 2) / params.baseWidth;
10442
- const maxScale = (_options$maxScale = options.maxScale) !== null && _options$maxScale !== void 0 ? _options$maxScale : Number.POSITIVE_INFINITY;
10362
+ const maxScale = options.maxScale ?? Number.POSITIVE_INFINITY;
10443
10363
  return Math.min(maxScale, Math.max(options.minScale, rawScale));
10444
10364
  }
10445
10365
  function resolveDocFitBaseWidth(params) {
@@ -10458,12 +10378,10 @@ let DocViewScaleService = class DocViewScaleService extends Disposable {
10458
10378
  this._configService = _configService;
10459
10379
  }
10460
10380
  getPluginConfig() {
10461
- var _this$_configService$;
10462
- return (_this$_configService$ = this._configService.getConfig("docs-ui.config")) !== null && _this$_configService$ !== void 0 ? _this$_configService$ : {};
10381
+ return this._configService.getConfig("docs-ui.config") ?? {};
10463
10382
  }
10464
10383
  getOptions() {
10465
- var _this$getPluginConfig;
10466
- return (_this$getPluginConfig = this.getPluginConfig().fitToWidth) !== null && _this$getPluginConfig !== void 0 ? _this$getPluginConfig : DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS;
10384
+ return this.getPluginConfig().fitToWidth ?? DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS;
10467
10385
  }
10468
10386
  getBaseWidth() {
10469
10387
  var _this$_context$unit, _this$_context$unit$g, _documentStyle$pageSi;
@@ -10498,10 +10416,7 @@ let DocViewScaleService = class DocViewScaleService extends Disposable {
10498
10416
  }
10499
10417
  _resolveContainer(container) {
10500
10418
  if (container == null) return;
10501
- if (typeof container === "string") {
10502
- var _ref, _document$querySelect;
10503
- return (_ref = (_document$querySelect = document.querySelector(container)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.getElementById(container)) !== null && _ref !== void 0 ? _ref : void 0;
10504
- }
10419
+ if (typeof container === "string") return document.querySelector(container) ?? document.getElementById(container) ?? void 0;
10505
10420
  return container;
10506
10421
  }
10507
10422
  };
@@ -10793,8 +10708,7 @@ function getPageSizeInModernMode(page) {
10793
10708
  //#endregion
10794
10709
  //#region src/basics/selection.ts
10795
10710
  function findFirstCursorOffset(snapshot) {
10796
- var _snapshot$body;
10797
- const { dataStream } = (_snapshot$body = snapshot.body) !== null && _snapshot$body !== void 0 ? _snapshot$body : {};
10711
+ const { dataStream } = snapshot.body ?? {};
10798
10712
  const EXCLUDE_TOKENS = [
10799
10713
  DataStreamTreeTokenType.TABLE_START,
10800
10714
  DataStreamTreeTokenType.TABLE_CELL_END,
@@ -10916,12 +10830,12 @@ const CloseHeaderFooterCommand = {
10916
10830
  id: "doc.command.close-header-footer",
10917
10831
  type: CommandType.COMMAND,
10918
10832
  handler: async (accessor, params) => {
10919
- var _params$unitId, _instanceService$getC, _renderObject$mainCom;
10833
+ var _instanceService$getC, _renderObject$mainCom;
10920
10834
  const commandService = accessor.get(ICommandService);
10921
10835
  const renderManagerService = accessor.get(IRenderManagerService);
10922
10836
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
10923
10837
  const instanceService = accessor.get(IUniverInstanceService);
10924
- const unitId = (_params$unitId = params === null || params === void 0 ? void 0 : params.unitId) !== null && _params$unitId !== void 0 ? _params$unitId : (_instanceService$getC = instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC)) === null || _instanceService$getC === void 0 ? void 0 : _instanceService$getC.getUnitId();
10838
+ const unitId = (params === null || params === void 0 ? void 0 : params.unitId) ?? ((_instanceService$getC = instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC)) === null || _instanceService$getC === void 0 ? void 0 : _instanceService$getC.getUnitId());
10925
10839
  if (unitId == null) return false;
10926
10840
  const renderObject = renderManagerService.getRenderUnitById(unitId);
10927
10841
  if (renderObject == null) return false;
@@ -11140,16 +11054,14 @@ const MODERN_WIDTH_OPTIONS = [
11140
11054
  ModernDocumentWidthMode.WIDE
11141
11055
  ];
11142
11056
  const getPaperSize = (size) => {
11143
- const result = Object.keys(PAGE_SIZE).find((key) => {
11057
+ return Object.keys(PAGE_SIZE).find((key) => {
11144
11058
  const { width, height } = PAGE_SIZE[key];
11145
11059
  if (size.width === width && size.height === height) return true;
11146
11060
  return false;
11147
- });
11148
- return result !== null && result !== void 0 ? result : "A4";
11061
+ }) ?? "A4";
11149
11062
  };
11150
11063
  const getModernWidthMode = (size) => {
11151
- var _size$width;
11152
- const width = (_size$width = size === null || size === void 0 ? void 0 : size.width) !== null && _size$width !== void 0 ? _size$width : MODERN_DOCUMENT_WIDTH[ModernDocumentWidthMode.MEDIUM];
11064
+ const width = (size === null || size === void 0 ? void 0 : size.width) ?? MODERN_DOCUMENT_WIDTH[ModernDocumentWidthMode.MEDIUM];
11153
11065
  return MODERN_WIDTH_OPTIONS.reduce((nearest, option) => {
11154
11066
  const nearestDistance = Math.abs(MODERN_DOCUMENT_WIDTH[nearest] - width);
11155
11067
  return Math.abs(MODERN_DOCUMENT_WIDTH[option] - width) < nearestDistance ? option : nearest;
@@ -11167,21 +11079,21 @@ function PageSettings(props) {
11167
11079
  const documentStyle = useDependency(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC).getDocumentStyle();
11168
11080
  const localeService = useDependency(LocaleService);
11169
11081
  const [settings, setSettings] = useState(() => {
11170
- var _documentStyle$pageSi, _documentStyle$pageSi2, _documentStyle$pageSi3, _documentStyle$pageSi4, _documentStyle$pageSi5, _documentStyle$pageOr, _documentStyle$margin, _documentStyle$margin2, _documentStyle$margin3, _documentStyle$margin4;
11082
+ var _documentStyle$pageSi, _documentStyle$pageSi2;
11171
11083
  return {
11172
11084
  mode: documentStyle.documentFlavor === DocumentFlavor.TRADITIONAL ? DocumentFlavor.TRADITIONAL : DocumentFlavor.MODERN,
11173
11085
  modernWidth: getModernWidthMode(documentStyle.pageSize),
11174
- paperSize: getPaperSize((_documentStyle$pageSi = documentStyle.pageSize) !== null && _documentStyle$pageSi !== void 0 ? _documentStyle$pageSi : PAGE_SIZE.A4),
11086
+ paperSize: getPaperSize(documentStyle.pageSize ?? PAGE_SIZE.A4),
11175
11087
  pageSize: {
11176
- width: (_documentStyle$pageSi2 = (_documentStyle$pageSi3 = documentStyle.pageSize) === null || _documentStyle$pageSi3 === void 0 ? void 0 : _documentStyle$pageSi3.width) !== null && _documentStyle$pageSi2 !== void 0 ? _documentStyle$pageSi2 : 0,
11177
- height: (_documentStyle$pageSi4 = (_documentStyle$pageSi5 = documentStyle.pageSize) === null || _documentStyle$pageSi5 === void 0 ? void 0 : _documentStyle$pageSi5.height) !== null && _documentStyle$pageSi4 !== void 0 ? _documentStyle$pageSi4 : 0
11088
+ width: ((_documentStyle$pageSi = documentStyle.pageSize) === null || _documentStyle$pageSi === void 0 ? void 0 : _documentStyle$pageSi.width) ?? 0,
11089
+ height: ((_documentStyle$pageSi2 = documentStyle.pageSize) === null || _documentStyle$pageSi2 === void 0 ? void 0 : _documentStyle$pageSi2.height) ?? 0
11178
11090
  },
11179
- orientation: (_documentStyle$pageOr = documentStyle.pageOrient) !== null && _documentStyle$pageOr !== void 0 ? _documentStyle$pageOr : PageOrientType.PORTRAIT,
11091
+ orientation: documentStyle.pageOrient ?? PageOrientType.PORTRAIT,
11180
11092
  margins: {
11181
- top: (_documentStyle$margin = documentStyle.marginTop) !== null && _documentStyle$margin !== void 0 ? _documentStyle$margin : 0,
11182
- bottom: (_documentStyle$margin2 = documentStyle.marginBottom) !== null && _documentStyle$margin2 !== void 0 ? _documentStyle$margin2 : 0,
11183
- left: (_documentStyle$margin3 = documentStyle.marginLeft) !== null && _documentStyle$margin3 !== void 0 ? _documentStyle$margin3 : 0,
11184
- right: (_documentStyle$margin4 = documentStyle.marginRight) !== null && _documentStyle$margin4 !== void 0 ? _documentStyle$margin4 : 0
11093
+ top: documentStyle.marginTop ?? 0,
11094
+ bottom: documentStyle.marginBottom ?? 0,
11095
+ left: documentStyle.marginLeft ?? 0,
11096
+ right: documentStyle.marginRight ?? 0
11185
11097
  }
11186
11098
  };
11187
11099
  });
@@ -11310,17 +11222,14 @@ const PAGE_SETTING_COMPONENT_ID = "docs.component.page-setting";
11310
11222
  //#region src/commands/commands/doc-page-setup.command.ts
11311
11223
  const PAGE_FILL_TABLE_TOLERANCE = 2;
11312
11224
  function getPageContentWidth(config) {
11313
- var _config$pageSize$widt, _config$pageSize, _config$marginLeft, _config$marginRight;
11314
- const pageWidth = (_config$pageSize$widt = (_config$pageSize = config.pageSize) === null || _config$pageSize === void 0 ? void 0 : _config$pageSize.width) !== null && _config$pageSize$widt !== void 0 ? _config$pageSize$widt : 0;
11225
+ var _config$pageSize;
11226
+ const pageWidth = ((_config$pageSize = config.pageSize) === null || _config$pageSize === void 0 ? void 0 : _config$pageSize.width) ?? 0;
11315
11227
  if (!pageWidth) return 0;
11316
11228
  if (config.documentFlavor === DocumentFlavor.MODERN) return Math.max(0, pageWidth - MODERN_DOCUMENT_DEFAULT_MARGIN * 2);
11317
- return Math.max(0, pageWidth - ((_config$marginLeft = config.marginLeft) !== null && _config$marginLeft !== void 0 ? _config$marginLeft : 0) - ((_config$marginRight = config.marginRight) !== null && _config$marginRight !== void 0 ? _config$marginRight : 0));
11229
+ return Math.max(0, pageWidth - (config.marginLeft ?? 0) - (config.marginRight ?? 0));
11318
11230
  }
11319
11231
  function getTableColumnTotalWidth(table) {
11320
- return table.tableColumns.reduce((total, column) => {
11321
- var _column$size$width$v;
11322
- return total + ((_column$size$width$v = column.size.width.v) !== null && _column$size$width$v !== void 0 ? _column$size$width$v : 0);
11323
- }, 0);
11232
+ return table.tableColumns.reduce((total, column) => total + (column.size.width.v ?? 0), 0);
11324
11233
  }
11325
11234
  function isPageFillTable(table, oldContentWidth) {
11326
11235
  if (oldContentWidth <= 0 || table.tableColumns.length === 0) return false;
@@ -11371,7 +11280,7 @@ const DocPageSetupCommand = {
11371
11280
  const snapshot = docDataModel.getSnapshot();
11372
11281
  const newDocumentStyle = {
11373
11282
  ...documentStyle,
11374
- documentFlavor: documentFlavor !== null && documentFlavor !== void 0 ? documentFlavor : documentStyle.documentFlavor,
11283
+ documentFlavor: documentFlavor ?? documentStyle.documentFlavor,
11375
11284
  marginBottom,
11376
11285
  marginLeft,
11377
11286
  marginRight,
@@ -11720,7 +11629,7 @@ const InsertSpecialCharacterCommand = {
11720
11629
  id: "doc.command.insert-special-character",
11721
11630
  type: CommandType.COMMAND,
11722
11631
  handler: (accessor, params) => {
11723
- var _docDataModel$getSelf, _originBody$customRan, _originBody$customDec;
11632
+ var _docDataModel$getSelf;
11724
11633
  if (!(params === null || params === void 0 ? void 0 : params.value)) return false;
11725
11634
  const commandService = accessor.get(ICommandService);
11726
11635
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
@@ -11734,8 +11643,8 @@ const InsertSpecialCharacterCommand = {
11734
11643
  if (!originBody) return false;
11735
11644
  const { value } = params;
11736
11645
  const curTextRun = getTextRunAtPosition(originBody, activeRange.endOffset, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache());
11737
- const curCustomRange = getCustomRangeAtPosition((_originBody$customRan = originBody.customRanges) !== null && _originBody$customRan !== void 0 ? _originBody$customRan : [], activeRange.endOffset);
11738
- const curCustomDecorations = getCustomDecorationAtPosition((_originBody$customDec = originBody.customDecorations) !== null && _originBody$customDec !== void 0 ? _originBody$customDec : [], activeRange.endOffset);
11646
+ const curCustomRange = getCustomRangeAtPosition(originBody.customRanges ?? [], activeRange.endOffset);
11647
+ const curCustomDecorations = getCustomDecorationAtPosition(originBody.customDecorations ?? [], activeRange.endOffset);
11739
11648
  return commandService.executeCommand(InsertTextCommand.id, {
11740
11649
  unitId: docDataModel.getUnitId(),
11741
11650
  body: {
@@ -11972,7 +11881,7 @@ function disableMenuWhenHeaderFooterEditing(accessor) {
11972
11881
  return;
11973
11882
  }
11974
11883
  const emitDisabled = (editArea) => {
11975
- const currentEditArea = editArea !== null && editArea !== void 0 ? editArea : viewModel.getEditArea();
11884
+ const currentEditArea = editArea ?? viewModel.getEditArea();
11976
11885
  emit(currentEditArea === DocumentEditArea.HEADER || currentEditArea === DocumentEditArea.FOOTER);
11977
11886
  };
11978
11887
  emitDisabled();
@@ -12066,7 +11975,7 @@ function disableMenuWhenNoDocRange(accessor) {
12066
11975
  const univerInstanceService = accessor.get(IUniverInstanceService);
12067
11976
  return new Observable((subscriber) => {
12068
11977
  const subscription = docSelectionManagerService.textSelection$.subscribe((selection) => {
12069
- var _document$getBody$blo, _document$getBody;
11978
+ var _document$getBody;
12070
11979
  if (selection == null) {
12071
11980
  subscriber.next(true);
12072
11981
  return;
@@ -12077,7 +11986,7 @@ function disableMenuWhenNoDocRange(accessor) {
12077
11986
  return;
12078
11987
  }
12079
11988
  const document = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
12080
- if (((_document$getBody$blo = document === null || document === void 0 || (_document$getBody = document.getBody()) === null || _document$getBody === void 0 || (_document$getBody = _document$getBody.blockRanges) === null || _document$getBody === void 0 ? void 0 : _document$getBody.filter((range) => range.blockType === DocumentBlockRangeType.CODE)) !== null && _document$getBody$blo !== void 0 ? _document$getBody$blo : []).some((blockRange) => textRanges.some((range) => Math.max(range.startOffset, blockRange.startIndex) <= Math.min(range.endOffset, blockRange.endIndex)))) {
11989
+ if (((document === null || document === void 0 || (_document$getBody = document.getBody()) === null || _document$getBody === void 0 || (_document$getBody = _document$getBody.blockRanges) === null || _document$getBody === void 0 ? void 0 : _document$getBody.filter((range) => range.blockType === DocumentBlockRangeType.CODE)) ?? []).some((blockRange) => textRanges.some((range) => Math.max(range.startOffset, blockRange.startIndex) <= Math.min(range.endOffset, blockRange.endIndex)))) {
12081
11990
  subscriber.next(true);
12082
11991
  return;
12083
11992
  }
@@ -12123,8 +12032,8 @@ function SymbolPickerMenuItemFactory(accessor) {
12123
12032
  };
12124
12033
  }
12125
12034
  function isTextRangeInAnyBlockRange(document, range) {
12126
- var _document$getBody$blo2, _document$getBody2;
12127
- const blockRanges = (_document$getBody$blo2 = document === null || document === void 0 || (_document$getBody2 = document.getBody()) === null || _document$getBody2 === void 0 ? void 0 : _document$getBody2.blockRanges) !== null && _document$getBody$blo2 !== void 0 ? _document$getBody$blo2 : [];
12035
+ var _document$getBody2;
12036
+ const blockRanges = (document === null || document === void 0 || (_document$getBody2 = document.getBody()) === null || _document$getBody2 === void 0 ? void 0 : _document$getBody2.blockRanges) ?? [];
12128
12037
  const startOffset = range.startOffset;
12129
12038
  const endOffset = range.collapsed ? range.startOffset : range.endOffset - 1;
12130
12039
  return blockRanges.some((blockRange) => Math.max(startOffset, blockRange.startIndex) <= Math.min(endOffset, blockRange.endIndex));
@@ -12134,10 +12043,10 @@ function hideMenuWhenSelectionInBlockRange(accessor) {
12134
12043
  const univerInstanceService = accessor.get(IUniverInstanceService);
12135
12044
  return new Observable((subscriber) => {
12136
12045
  const calc = (selection) => {
12137
- var _getCurrentSelection, _selection$textRanges, _docSelectionManagerS, _selection$unitId;
12046
+ var _getCurrentSelection;
12138
12047
  const currentSelection = (_getCurrentSelection = docSelectionManagerService.__getCurrentSelection) === null || _getCurrentSelection === void 0 ? void 0 : _getCurrentSelection.call(docSelectionManagerService);
12139
- const textRanges = (_selection$textRanges = selection === null || selection === void 0 ? void 0 : selection.textRanges) !== null && _selection$textRanges !== void 0 ? _selection$textRanges : [...(_docSelectionManagerS = docSelectionManagerService.getTextRanges()) !== null && _docSelectionManagerS !== void 0 ? _docSelectionManagerS : []];
12140
- const unitId = (_selection$unitId = selection === null || selection === void 0 ? void 0 : selection.unitId) !== null && _selection$unitId !== void 0 ? _selection$unitId : currentSelection === null || currentSelection === void 0 ? void 0 : currentSelection.unitId;
12048
+ const textRanges = (selection === null || selection === void 0 ? void 0 : selection.textRanges) ?? [...docSelectionManagerService.getTextRanges() ?? []];
12049
+ const unitId = (selection === null || selection === void 0 ? void 0 : selection.unitId) ?? (currentSelection === null || currentSelection === void 0 ? void 0 : currentSelection.unitId);
12141
12050
  const document = unitId ? univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC) : univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
12142
12051
  subscriber.next(textRanges.some((range) => isTextRangeInAnyBlockRange(document, range)));
12143
12052
  };
@@ -12357,7 +12266,7 @@ function FontFamilySelectorMenuItemFactory(accessor) {
12357
12266
  return;
12358
12267
  }
12359
12268
  const ff = (_textRun$ts7 = textRun.ts) === null || _textRun$ts7 === void 0 ? void 0 : _textRun$ts7.ff;
12360
- subscriber.next(ff !== null && ff !== void 0 ? ff : defaultValue);
12269
+ subscriber.next(ff ?? defaultValue);
12361
12270
  };
12362
12271
  const disposable = commandService.onCommandExecuted((c) => {
12363
12272
  const id = c.id;
@@ -12395,7 +12304,7 @@ function FontSizeSelectorMenuItemFactory(accessor) {
12395
12304
  return;
12396
12305
  }
12397
12306
  const fs = (_textRun$ts8 = textRun.ts) === null || _textRun$ts8 === void 0 ? void 0 : _textRun$ts8.fs;
12398
- subscriber.next(fs !== null && fs !== void 0 ? fs : DEFAULT_SIZE);
12307
+ subscriber.next(fs ?? DEFAULT_SIZE);
12399
12308
  };
12400
12309
  const disposable = commandService.onCommandExecuted((c) => {
12401
12310
  const id = c.id;
@@ -12431,14 +12340,14 @@ function HeadingSelectorMenuItemFactory(accessor) {
12431
12340
  value$: new Observable((subscriber) => {
12432
12341
  const DEFAULT_TYPE = NamedStyleType.NORMAL_TEXT;
12433
12342
  const calc = () => {
12434
- var _paragraph$paragraphS, _paragraph$paragraphS2;
12343
+ var _paragraph$paragraphS;
12435
12344
  if (shouldSuppressDocMenuStateRefresh(accessor)) return;
12436
12345
  const paragraph = getParagraphStyleAtCursor(accessor);
12437
12346
  if (paragraph == null) {
12438
12347
  subscriber.next(DEFAULT_TYPE);
12439
12348
  return;
12440
12349
  }
12441
- const namedStyleType = (_paragraph$paragraphS = (_paragraph$paragraphS2 = paragraph.paragraphStyle) === null || _paragraph$paragraphS2 === void 0 ? void 0 : _paragraph$paragraphS2.namedStyleType) !== null && _paragraph$paragraphS !== void 0 ? _paragraph$paragraphS : DEFAULT_TYPE;
12350
+ const namedStyleType = ((_paragraph$paragraphS = paragraph.paragraphStyle) === null || _paragraph$paragraphS === void 0 ? void 0 : _paragraph$paragraphS.namedStyleType) ?? DEFAULT_TYPE;
12442
12351
  subscriber.next(namedStyleType);
12443
12352
  };
12444
12353
  const disposable = commandService.onCommandExecuted((c) => {
@@ -12505,12 +12414,12 @@ const FLOAT_TEXT_STYLE_OPTIONS = [
12505
12414
  }
12506
12415
  ];
12507
12416
  function normalizeFloatingTextStyleValue(paragraph) {
12508
- var _paragraph$bullet, _paragraph$paragraphS3, _paragraph$paragraphS4;
12417
+ var _paragraph$bullet, _paragraph$paragraphS2;
12509
12418
  const listType = paragraph === null || paragraph === void 0 || (_paragraph$bullet = paragraph.bullet) === null || _paragraph$bullet === void 0 ? void 0 : _paragraph$bullet.listType;
12510
12419
  if (listType === null || listType === void 0 ? void 0 : listType.startsWith(PresetListType.ORDER_LIST)) return PresetListType.ORDER_LIST;
12511
12420
  if (listType === null || listType === void 0 ? void 0 : listType.startsWith(PresetListType.BULLET_LIST)) return PresetListType.BULLET_LIST;
12512
12421
  if (listType === PresetListType.CHECK_LIST || listType === PresetListType.CHECK_LIST_CHECKED) return PresetListType.CHECK_LIST;
12513
- return (_paragraph$paragraphS3 = paragraph === null || paragraph === void 0 || (_paragraph$paragraphS4 = paragraph.paragraphStyle) === null || _paragraph$paragraphS4 === void 0 ? void 0 : _paragraph$paragraphS4.namedStyleType) !== null && _paragraph$paragraphS3 !== void 0 ? _paragraph$paragraphS3 : NamedStyleType.NORMAL_TEXT;
12422
+ return (paragraph === null || paragraph === void 0 || (_paragraph$paragraphS2 = paragraph.paragraphStyle) === null || _paragraph$paragraphS2 === void 0 ? void 0 : _paragraph$paragraphS2.namedStyleType) ?? NamedStyleType.NORMAL_TEXT;
12514
12423
  }
12515
12424
  function FloatTextStyleMenuItemFactory(accessor) {
12516
12425
  const commandService = accessor.get(ICommandService);
@@ -12562,7 +12471,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
12562
12471
  return;
12563
12472
  }
12564
12473
  const color = (_textRun$ts9 = textRun.ts) === null || _textRun$ts9 === void 0 || (_textRun$ts9 = _textRun$ts9.cl) === null || _textRun$ts9 === void 0 ? void 0 : _textRun$ts9.rgb;
12565
- subscriber.next(color !== null && color !== void 0 ? color : defaultValue);
12474
+ subscriber.next(color ?? defaultValue);
12566
12475
  };
12567
12476
  const disposable = commandService.onCommandExecuted((c) => {
12568
12477
  if (c.id === SetInlineFormatTextColorCommand.id) calc();
@@ -12577,7 +12486,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
12577
12486
  if (c.id === SetInlineFormatTextColorCommand.id) {
12578
12487
  if (shouldSuppressDocMenuStateRefresh(accessor)) return;
12579
12488
  const color = c.params.value;
12580
- subscriber.next(color !== null && color !== void 0 ? color : defaultColor);
12489
+ subscriber.next(color ?? defaultColor);
12581
12490
  }
12582
12491
  });
12583
12492
  subscriber.next(defaultColor);
@@ -12696,11 +12605,11 @@ function AlignLeftMenuItemFactory(accessor) {
12696
12605
  const disposable = commandService.onCommandExecuted((c) => {
12697
12606
  const id = c.id;
12698
12607
  if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
12699
- var _paragraph$paragraphS5;
12608
+ var _paragraph$paragraphS3;
12700
12609
  if (shouldSuppressDocMenuStateRefresh(accessor)) return;
12701
12610
  const paragraph = getParagraphStyleAtCursor(accessor);
12702
12611
  if (paragraph == null) return;
12703
- const alignType = (_paragraph$paragraphS5 = paragraph.paragraphStyle) === null || _paragraph$paragraphS5 === void 0 ? void 0 : _paragraph$paragraphS5.horizontalAlign;
12612
+ const alignType = (_paragraph$paragraphS3 = paragraph.paragraphStyle) === null || _paragraph$paragraphS3 === void 0 ? void 0 : _paragraph$paragraphS3.horizontalAlign;
12704
12613
  subscriber.next(alignType === HorizontalAlign.LEFT);
12705
12614
  }
12706
12615
  });
@@ -12721,11 +12630,11 @@ function AlignCenterMenuItemFactory(accessor) {
12721
12630
  const disposable = commandService.onCommandExecuted((c) => {
12722
12631
  const id = c.id;
12723
12632
  if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
12724
- var _paragraph$paragraphS6;
12633
+ var _paragraph$paragraphS4;
12725
12634
  if (shouldSuppressDocMenuStateRefresh(accessor)) return;
12726
12635
  const paragraph = getParagraphStyleAtCursor(accessor);
12727
12636
  if (paragraph == null) return;
12728
- const alignType = (_paragraph$paragraphS6 = paragraph.paragraphStyle) === null || _paragraph$paragraphS6 === void 0 ? void 0 : _paragraph$paragraphS6.horizontalAlign;
12637
+ const alignType = (_paragraph$paragraphS4 = paragraph.paragraphStyle) === null || _paragraph$paragraphS4 === void 0 ? void 0 : _paragraph$paragraphS4.horizontalAlign;
12729
12638
  subscriber.next(alignType === HorizontalAlign.CENTER);
12730
12639
  }
12731
12640
  });
@@ -12747,11 +12656,11 @@ function AlignRightMenuItemFactory(accessor) {
12747
12656
  const disposable = commandService.onCommandExecuted((c) => {
12748
12657
  const id = c.id;
12749
12658
  if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
12750
- var _paragraph$paragraphS7;
12659
+ var _paragraph$paragraphS5;
12751
12660
  if (shouldSuppressDocMenuStateRefresh(accessor)) return;
12752
12661
  const paragraph = getParagraphStyleAtCursor(accessor);
12753
12662
  if (paragraph == null) return;
12754
- const alignType = (_paragraph$paragraphS7 = paragraph.paragraphStyle) === null || _paragraph$paragraphS7 === void 0 ? void 0 : _paragraph$paragraphS7.horizontalAlign;
12663
+ const alignType = (_paragraph$paragraphS5 = paragraph.paragraphStyle) === null || _paragraph$paragraphS5 === void 0 ? void 0 : _paragraph$paragraphS5.horizontalAlign;
12755
12664
  subscriber.next(alignType === HorizontalAlign.RIGHT);
12756
12665
  }
12757
12666
  });
@@ -12773,11 +12682,11 @@ function AlignJustifyMenuItemFactory(accessor) {
12773
12682
  const disposable = commandService.onCommandExecuted((c) => {
12774
12683
  const id = c.id;
12775
12684
  if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
12776
- var _paragraph$paragraphS8;
12685
+ var _paragraph$paragraphS6;
12777
12686
  if (shouldSuppressDocMenuStateRefresh(accessor)) return;
12778
12687
  const paragraph = getParagraphStyleAtCursor(accessor);
12779
12688
  if (paragraph == null) return;
12780
- const alignType = (_paragraph$paragraphS8 = paragraph.paragraphStyle) === null || _paragraph$paragraphS8 === void 0 ? void 0 : _paragraph$paragraphS8.horizontalAlign;
12689
+ const alignType = (_paragraph$paragraphS6 = paragraph.paragraphStyle) === null || _paragraph$paragraphS6 === void 0 ? void 0 : _paragraph$paragraphS6.horizontalAlign;
12781
12690
  subscriber.next(alignType === HorizontalAlign.JUSTIFIED);
12782
12691
  }
12783
12692
  });
@@ -12818,13 +12727,13 @@ function AlignMenuItemFactory(accessor) {
12818
12727
  const commandService = accessor.get(ICommandService);
12819
12728
  const value$ = new Observable((subscriber) => {
12820
12729
  const calc = () => {
12821
- var _paragraph$paragraphS9, _paragraph$paragraphS10;
12730
+ var _paragraph$paragraphS7;
12822
12731
  if (shouldSuppressDocMenuStateRefresh(accessor)) {
12823
12732
  subscriber.next(HorizontalAlign.LEFT);
12824
12733
  return;
12825
12734
  }
12826
12735
  const paragraph = getParagraphStyleAtCursor(accessor);
12827
- subscriber.next((_paragraph$paragraphS9 = paragraph === null || paragraph === void 0 || (_paragraph$paragraphS10 = paragraph.paragraphStyle) === null || _paragraph$paragraphS10 === void 0 ? void 0 : _paragraph$paragraphS10.horizontalAlign) !== null && _paragraph$paragraphS9 !== void 0 ? _paragraph$paragraphS9 : HorizontalAlign.LEFT);
12736
+ subscriber.next((paragraph === null || paragraph === void 0 || (_paragraph$paragraphS7 = paragraph.paragraphStyle) === null || _paragraph$paragraphS7 === void 0 ? void 0 : _paragraph$paragraphS7.horizontalAlign) ?? HorizontalAlign.LEFT);
12828
12737
  };
12829
12738
  const disposable = commandService.onCommandExecuted((c) => {
12830
12739
  if (c.id === SetTextSelectionsOperation.id || c.id === AlignOperationCommand.id) calc();
@@ -12839,8 +12748,8 @@ function AlignMenuItemFactory(accessor) {
12839
12748
  id: AlignOperationCommand.id,
12840
12749
  type: MenuItemType.SELECTOR,
12841
12750
  icon: value$.pipe(map((alignType) => {
12842
- var _HORIZONTAL_ALIGN_OPT, _HORIZONTAL_ALIGN_OPT2;
12843
- return (_HORIZONTAL_ALIGN_OPT = (_HORIZONTAL_ALIGN_OPT2 = HORIZONTAL_ALIGN_OPTIONS.find((option) => option.value === alignType)) === null || _HORIZONTAL_ALIGN_OPT2 === void 0 ? void 0 : _HORIZONTAL_ALIGN_OPT2.icon) !== null && _HORIZONTAL_ALIGN_OPT !== void 0 ? _HORIZONTAL_ALIGN_OPT : "LeftJustifyingIcon";
12751
+ var _HORIZONTAL_ALIGN_OPT;
12752
+ return ((_HORIZONTAL_ALIGN_OPT = HORIZONTAL_ALIGN_OPTIONS.find((option) => option.value === alignType)) === null || _HORIZONTAL_ALIGN_OPT === void 0 ? void 0 : _HORIZONTAL_ALIGN_OPT.icon) ?? "LeftJustifyingIcon";
12844
12753
  })),
12845
12754
  tooltip: "docs-ui.toolbar.alignLeft",
12846
12755
  selections: HORIZONTAL_ALIGN_OPTIONS,
@@ -12864,17 +12773,16 @@ const listValueFactory$ = (accessor) => {
12864
12773
  const univerInstanceService = accessor.get(IUniverInstanceService);
12865
12774
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
12866
12775
  const subscription = univerInstanceService.focused$.subscribe((unitId) => {
12867
- var _docRanges$find;
12868
12776
  if (shouldSuppressDocMenuStateRefresh(accessor)) return;
12869
12777
  if (unitId == null) return;
12870
12778
  const docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
12871
12779
  if (docDataModel == null) return;
12872
12780
  const docRanges = docSelectionManagerService.getDocRanges();
12873
- const range = (_docRanges$find = docRanges.find((r) => r.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
12781
+ const range = docRanges.find((r) => r.isActive) ?? docRanges[0];
12874
12782
  if (range) {
12875
- var _doc$getBody$paragrap, _doc$getBody, _doc$getBody$dataStre, _doc$getBody2;
12783
+ var _doc$getBody, _doc$getBody2;
12876
12784
  const doc = docDataModel.getSelfOrHeaderFooterModel(range === null || range === void 0 ? void 0 : range.segmentId);
12877
- const paragraphs = BuildTextUtils.range.getParagraphsInRange(range, (_doc$getBody$paragrap = doc === null || doc === void 0 || (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.paragraphs) !== null && _doc$getBody$paragrap !== void 0 ? _doc$getBody$paragrap : [], (_doc$getBody$dataStre = doc === null || doc === void 0 || (_doc$getBody2 = doc.getBody()) === null || _doc$getBody2 === void 0 ? void 0 : _doc$getBody2.dataStream) !== null && _doc$getBody$dataStre !== void 0 ? _doc$getBody$dataStre : "");
12785
+ const paragraphs = BuildTextUtils.range.getParagraphsInRange(range, (doc === null || doc === void 0 || (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.paragraphs) ?? [], (doc === null || doc === void 0 || (_doc$getBody2 = doc.getBody()) === null || _doc$getBody2 === void 0 ? void 0 : _doc$getBody2.dataStream) ?? "");
12878
12786
  let listType;
12879
12787
  if (paragraphs.every((p) => {
12880
12788
  if (!listType) {
@@ -12986,7 +12894,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
12986
12894
  return;
12987
12895
  }
12988
12896
  const color = (_textRun$ts10 = textRun.ts) === null || _textRun$ts10 === void 0 || (_textRun$ts10 = _textRun$ts10.bg) === null || _textRun$ts10 === void 0 ? void 0 : _textRun$ts10.rgb;
12989
- subscriber.next(color !== null && color !== void 0 ? color : defaultValue);
12897
+ subscriber.next(color ?? defaultValue);
12990
12898
  };
12991
12899
  const disposable = commandService.onCommandExecuted((c) => {
12992
12900
  if (c.id === SetInlineFormatTextBackgroundColorCommand.id) calc();
@@ -13001,7 +12909,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
13001
12909
  if (c.id === SetInlineFormatTextBackgroundColorCommand.id) {
13002
12910
  if (shouldSuppressDocMenuStateRefresh(accessor)) return;
13003
12911
  const color = c.params.value;
13004
- subscriber.next(color !== null && color !== void 0 ? color : defaultColor);
12912
+ subscriber.next(color ?? defaultColor);
13005
12913
  }
13006
12914
  });
13007
12915
  subscriber.next(defaultColor);
@@ -13012,7 +12920,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
13012
12920
  };
13013
12921
  }
13014
12922
  function getFontStyleAtCursor(accessor) {
13015
- var _docRanges$find2, _docMenuStyleService$, _paragraph$paragraphS11, _paragraph$paragraphS12, _docDataModel$getSelf;
12923
+ var _paragraph$paragraphS8, _paragraph$paragraphS9, _docDataModel$getSelf;
13016
12924
  if (shouldSuppressDocMenuStateRefresh(accessor)) return;
13017
12925
  let univerInstanceService;
13018
12926
  let textSelectionService;
@@ -13027,11 +12935,11 @@ function getFontStyleAtCursor(accessor) {
13027
12935
  }
13028
12936
  const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
13029
12937
  const docRanges = textSelectionService.getDocRanges();
13030
- const activeRange = (_docRanges$find2 = docRanges.find((r) => r.isActive)) !== null && _docRanges$find2 !== void 0 ? _docRanges$find2 : docRanges[0];
12938
+ const activeRange = docRanges.find((r) => r.isActive) ?? docRanges[0];
13031
12939
  const defaultTextStyle = docMenuStyleService.getDefaultStyle();
13032
- const cacheStyle = (_docMenuStyleService$ = docMenuStyleService.getStyleCache()) !== null && _docMenuStyleService$ !== void 0 ? _docMenuStyleService$ : {};
12940
+ const cacheStyle = docMenuStyleService.getStyleCache() ?? {};
13033
12941
  const paragraph = getParagraphStyleAtCursor(accessor);
13034
- const namedStyle = (paragraph === null || paragraph === void 0 || (_paragraph$paragraphS11 = paragraph.paragraphStyle) === null || _paragraph$paragraphS11 === void 0 ? void 0 : _paragraph$paragraphS11.namedStyleType) ? NAMED_STYLE_MAP[paragraph === null || paragraph === void 0 || (_paragraph$paragraphS12 = paragraph.paragraphStyle) === null || _paragraph$paragraphS12 === void 0 ? void 0 : _paragraph$paragraphS12.namedStyleType] : null;
12942
+ const namedStyle = (paragraph === null || paragraph === void 0 || (_paragraph$paragraphS8 = paragraph.paragraphStyle) === null || _paragraph$paragraphS8 === void 0 ? void 0 : _paragraph$paragraphS8.namedStyleType) ? NAMED_STYLE_MAP[paragraph === null || paragraph === void 0 || (_paragraph$paragraphS9 = paragraph.paragraphStyle) === null || _paragraph$paragraphS9 === void 0 ? void 0 : _paragraph$paragraphS9.namedStyleType] : null;
13035
12943
  if (docDataModel == null || activeRange == null) return { ts: {
13036
12944
  ...defaultTextStyle,
13037
12945
  ...namedStyle,
@@ -13054,7 +12962,7 @@ function getFontStyleAtCursor(accessor) {
13054
12962
  } };
13055
12963
  }
13056
12964
  function getParagraphStyleAtCursor(accessor) {
13057
- var _docRanges$find3, _docDataModel$getSelf2;
12965
+ var _docDataModel$getSelf2;
13058
12966
  if (shouldSuppressDocMenuStateRefresh(accessor)) return;
13059
12967
  let univerInstanceService;
13060
12968
  let textSelectionService;
@@ -13067,7 +12975,7 @@ function getParagraphStyleAtCursor(accessor) {
13067
12975
  }
13068
12976
  const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
13069
12977
  const docRanges = textSelectionService.getDocRanges();
13070
- const activeRange = (_docRanges$find3 = docRanges.find((r) => r.isActive)) !== null && _docRanges$find3 !== void 0 ? _docRanges$find3 : docRanges[0];
12978
+ const activeRange = docRanges.find((r) => r.isActive) ?? docRanges[0];
13071
12979
  if (docDataModel == null || activeRange == null) return;
13072
12980
  const { startOffset, segmentId } = activeRange;
13073
12981
  const paragraphs = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 || (_docDataModel$getSelf2 = _docDataModel$getSelf2.getBody()) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.paragraphs;
@@ -13097,11 +13005,10 @@ function PageSettingMenuItemFactory(accessor) {
13097
13005
  //#endregion
13098
13006
  //#region src/views/paragraph-menu/theme-color.ts
13099
13007
  function getHighlightBackgroundColor(themeService, index) {
13100
- var _themeService$getColo;
13101
13008
  const tokenPath = `highlight.background.${index + 1}`;
13102
13009
  const token = themeService.getColorFromTheme(tokenPath);
13103
13010
  if (token == null || typeof token.color !== "string" || typeof token.alpha !== "number") throw new Error(`Theme token ${tokenPath} is required.`);
13104
- return new ColorKit((_themeService$getColo = themeService.getColorFromTheme(token.color)) !== null && _themeService$getColo !== void 0 ? _themeService$getColo : token.color).setAlpha(token.alpha).toRgbString();
13011
+ return new ColorKit(themeService.getColorFromTheme(token.color) ?? token.color).setAlpha(token.alpha).toRgbString();
13105
13012
  }
13106
13013
 
13107
13014
  //#endregion
@@ -13139,22 +13046,21 @@ const BACKGROUND_COLOR_SWATCH_ICONS = [
13139
13046
  "DocParagraphBackgroundColorSwatchIcon.11",
13140
13047
  "DocParagraphBackgroundColorSwatchIcon.12",
13141
13048
  "DocParagraphBackgroundColorSwatchIcon.13",
13142
- "DocParagraphBackgroundColorSwatchIcon.14",
13143
- "DocParagraphBackgroundColorSwatchIcon.15"
13049
+ "DocParagraphBackgroundColorSwatchIcon.14"
13144
13050
  ];
13145
13051
  function getHeadingActivatedObservable(accessor, headingType) {
13146
13052
  const commandService = accessor.get(ICommandService);
13147
13053
  return new Observable((subscriber) => {
13148
13054
  const DEFAULT_TYPE = NamedStyleType.NORMAL_TEXT;
13149
13055
  const calc = () => {
13150
- var _paragraph$paragraphS, _paragraph$paragraphS2;
13056
+ var _paragraph$paragraphS;
13151
13057
  if (shouldSuppressDocMenuStateRefresh(accessor)) return;
13152
13058
  const paragraph = getParagraphStyleAtCursor(accessor);
13153
13059
  if (paragraph == null) {
13154
13060
  subscriber.next(DEFAULT_TYPE === headingType);
13155
13061
  return;
13156
13062
  }
13157
- const namedStyleType = (_paragraph$paragraphS = (_paragraph$paragraphS2 = paragraph.paragraphStyle) === null || _paragraph$paragraphS2 === void 0 ? void 0 : _paragraph$paragraphS2.namedStyleType) !== null && _paragraph$paragraphS !== void 0 ? _paragraph$paragraphS : DEFAULT_TYPE;
13063
+ const namedStyleType = ((_paragraph$paragraphS = paragraph.paragraphStyle) === null || _paragraph$paragraphS === void 0 ? void 0 : _paragraph$paragraphS.namedStyleType) ?? DEFAULT_TYPE;
13158
13064
  subscriber.next(namedStyleType === headingType);
13159
13065
  };
13160
13066
  const disposable = commandService.onCommandExecuted((c) => {
@@ -14680,9 +14586,8 @@ function CountBar(_props) {
14680
14586
  //#endregion
14681
14587
  //#region src/views/doc-footer/DocFooter.tsx
14682
14588
  function DocFooterContent() {
14683
- var _config$footer;
14684
14589
  const config = useConfigValue(DOCS_UI_PLUGIN_CONFIG_KEY);
14685
- return ((_config$footer = config === null || config === void 0 ? void 0 : config.footer) !== null && _config$footer !== void 0 ? _config$footer : true) && /* @__PURE__ */ jsxs("div", {
14590
+ return ((config === null || config === void 0 ? void 0 : config.footer) ?? true) && /* @__PURE__ */ jsxs("div", {
14686
14591
  className: "univer-box-border univer-flex univer-items-center univer-justify-between univer-px-5 univer-py-1.5",
14687
14592
  children: [/* @__PURE__ */ jsx("div", {}), /* @__PURE__ */ jsx(CountBar, {})]
14688
14593
  });
@@ -14847,8 +14752,7 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
14847
14752
  return this._createRectPositionObserver(getBound, currentRender);
14848
14753
  }
14849
14754
  _createRangePositionObserver(range, currentRender) {
14850
- var _calcDocRangePosition;
14851
- const positions = (_calcDocRangePosition = calcDocRangePositions(range, currentRender)) !== null && _calcDocRangePosition !== void 0 ? _calcDocRangePosition : [];
14755
+ const positions = calcDocRangePositions(range, currentRender) ?? [];
14852
14756
  const positions$ = new BehaviorSubject(positions);
14853
14757
  const disposable = new DisposableCollection();
14854
14758
  disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
@@ -14954,7 +14858,7 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
14954
14858
  "top",
14955
14859
  "bottom",
14956
14860
  "horizontal"
14957
- ].some((i) => direction.includes(i)) ? bounds.length > 1 ? multipleDirection !== null && multipleDirection !== void 0 ? multipleDirection : direction : direction : direction,
14861
+ ].some((i) => direction.includes(i)) ? bounds.length > 1 ? multipleDirection ?? direction : direction : direction,
14958
14862
  canvasElement: currentRender.engine.getCanvasElement()
14959
14863
  });
14960
14864
  return {
@@ -14985,8 +14889,8 @@ const calcDocRangePositions$1 = (range, documents, skeleton, pageIndex) => {
14985
14889
  const skeletonData = skeleton.getSkeletonData();
14986
14890
  let end = range.collapsed ? range.startOffset : range.endOffset - 1;
14987
14891
  if (range.segmentId) {
14988
- var _Array$from$, _skeletonData$skeFoot, _skeletonData$skeFoot2, _skeletonData$skeHead, _skeletonData$skeHead2;
14989
- const root = (_Array$from$ = Array.from((_skeletonData$skeFoot = skeletonData === null || skeletonData === void 0 || (_skeletonData$skeFoot2 = skeletonData.skeFooters.get(range.segmentId)) === null || _skeletonData$skeFoot2 === void 0 ? void 0 : _skeletonData$skeFoot2.values()) !== null && _skeletonData$skeFoot !== void 0 ? _skeletonData$skeFoot : [])[0]) !== null && _Array$from$ !== void 0 ? _Array$from$ : Array.from((_skeletonData$skeHead = skeletonData === null || skeletonData === void 0 || (_skeletonData$skeHead2 = skeletonData.skeHeaders.get(range.segmentId)) === null || _skeletonData$skeHead2 === void 0 ? void 0 : _skeletonData$skeHead2.values()) !== null && _skeletonData$skeHead !== void 0 ? _skeletonData$skeHead : [])[0];
14892
+ var _skeletonData$skeFoot, _skeletonData$skeHead;
14893
+ const root = Array.from((skeletonData === null || skeletonData === void 0 || (_skeletonData$skeFoot = skeletonData.skeFooters.get(range.segmentId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.values()) ?? [])[0] ?? Array.from((skeletonData === null || skeletonData === void 0 || (_skeletonData$skeHead = skeletonData.skeHeaders.get(range.segmentId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.values()) ?? [])[0];
14990
14894
  if (root) end = Math.min(root.ed, end);
14991
14895
  }
14992
14896
  const endPosition = skeleton.findNodePositionByCharIndex(end, true, range.segmentId, pageIndex);
@@ -15080,7 +14984,7 @@ const calcParagraphPositionsFromLineContexts = (contexts, docsLeft, docsTop) =>
15080
14984
  };
15081
14985
  function getParagraphLineBottom(context, lineTop) {
15082
14986
  const lineBottom = lineTop + context.line.lineHeight;
15083
- if (context.source !== "column" || context.line !== context.column.lines.at(-1) || !Number.isFinite(context.page.pageHeight)) return lineBottom;
14987
+ if (context.source !== "column" || context.line !== context.column.lines[context.column.lines.length - 1] || !Number.isFinite(context.page.pageHeight)) return lineBottom;
15084
14988
  const pageTop = lineTop - context.line.top - context.section.top;
15085
14989
  return Math.max(lineBottom, pageTop + context.page.pageHeight);
15086
14990
  }
@@ -15159,9 +15063,8 @@ function getTableBlockMenuHoverRect(tableRect) {
15159
15063
  };
15160
15064
  }
15161
15065
  function getTableHorizontalViewportGeometry(tableLeft, tableWidth, viewport) {
15162
- var _viewport$leadingInse;
15163
15066
  const hasHorizontalViewport = hasHorizontalTableViewport(viewport);
15164
- const visibleLeft = hasHorizontalViewport ? tableLeft - ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0) : tableLeft;
15067
+ const visibleLeft = hasHorizontalViewport ? tableLeft - (viewport.leadingInsetLeft ?? 0) : tableLeft;
15165
15068
  return {
15166
15069
  scrollLeft: hasHorizontalViewport ? viewport.scrollLeft : 0,
15167
15070
  visibleLeft,
@@ -15169,8 +15072,7 @@ function getTableHorizontalViewportGeometry(tableLeft, tableWidth, viewport) {
15169
15072
  };
15170
15073
  }
15171
15074
  function hasHorizontalTableViewport(viewport) {
15172
- var _viewport$leadingInse2, _viewport$trailingIns;
15173
- return viewport != null && ((_viewport$leadingInse2 = viewport.leadingInsetLeft) !== null && _viewport$leadingInse2 !== void 0 ? _viewport$leadingInse2 : 0) + viewport.contentWidth + ((_viewport$trailingIns = viewport.trailingInsetRight) !== null && _viewport$trailingIns !== void 0 ? _viewport$trailingIns : 0) > viewport.viewportWidth;
15075
+ return viewport != null && (viewport.leadingInsetLeft ?? 0) + viewport.contentWidth + (viewport.trailingInsetRight ?? 0) > viewport.viewportWidth;
15174
15076
  }
15175
15077
  let DocEventManagerService = class DocEventManagerService extends Disposable {
15176
15078
  get hoverParagraph() {
@@ -15302,8 +15204,7 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15302
15204
  })))), filter(({ down, up }) => down.target === up.target && (down.button === 2 || up.timeStamp - down.timeStamp < 300))).subscribe(({ down }) => {
15303
15205
  const point = transformOffset2Bound(down.offsetX, down.offsetY, this._context.scene);
15304
15206
  if (down.button === 2) {
15305
- var _this$_calcActiveBull;
15306
- const bullet = (_this$_calcActiveBull = this._calcActiveBullet(point)) !== null && _this$_calcActiveBull !== void 0 ? _this$_calcActiveBull : this._calcActiveListParagraph(point);
15207
+ const bullet = this._calcActiveBullet(point) ?? this._calcActiveListParagraph(point);
15307
15208
  if (bullet) this._contextMenuBullet$.next({
15308
15209
  ...bullet,
15309
15210
  x: down.offsetX,
@@ -15330,13 +15231,12 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15330
15231
  return [...this._bulletBounds];
15331
15232
  }
15332
15233
  getListContextMenuBulletByOffset(offsetX, offsetY) {
15333
- var _this$_calcActiveBull2;
15334
15234
  const point = transformOffset2Bound(offsetX, offsetY, this._context.scene);
15335
- return (_this$_calcActiveBull2 = this._calcActiveBullet(point)) !== null && _this$_calcActiveBull2 !== void 0 ? _this$_calcActiveBull2 : this._calcActiveListParagraph(point);
15235
+ return this._calcActiveBullet(point) ?? this._calcActiveListParagraph(point);
15336
15236
  }
15337
15237
  _buildCustomRangeBoundsBySegment(segmentId, segmentPage = -1) {
15338
- var _this$_context$unit$g, _this$_context$unit$g2;
15339
- 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 : [];
15238
+ var _this$_context$unit$g;
15239
+ const customRanges = ((_this$_context$unit$g = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.getBody()) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.customRanges) ?? [];
15340
15240
  const layouts = [];
15341
15241
  customRanges.forEach((range) => {
15342
15242
  const textRange = {
@@ -15381,9 +15281,9 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15381
15281
  }));
15382
15282
  }
15383
15283
  _buildBulletBoundsBySegment(segmentId, segmentPage = -1) {
15384
- var _this$_context$unit$g3, _body$paragraphs;
15385
- const body = (_this$_context$unit$g3 = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) === null || _this$_context$unit$g3 === void 0 ? void 0 : _this$_context$unit$g3.getBody();
15386
- const paragraphs = ((_body$paragraphs = body === null || body === void 0 ? void 0 : body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).filter((p) => p.bullet);
15284
+ var _this$_context$unit$g2;
15285
+ const body = (_this$_context$unit$g2 = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) === null || _this$_context$unit$g2 === void 0 ? void 0 : _this$_context$unit$g2.getBody();
15286
+ const paragraphs = ((body === null || body === void 0 ? void 0 : body.paragraphs) ?? []).filter((p) => p.bullet);
15387
15287
  const bounds = [];
15388
15288
  const skeletonData = this._skeleton.getSkeletonData();
15389
15289
  if (!skeletonData) return bounds;
@@ -15415,8 +15315,8 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15415
15315
  return bounds;
15416
15316
  };
15417
15317
  if (segmentId) {
15418
- var _skeletonData$skeFoot3, _skeletonData$skeFoot4, _skeletonData$skeHead3;
15419
- const page = (_skeletonData$skeFoot3 = (_skeletonData$skeFoot4 = skeletonData.skeFooters.get(segmentId)) === null || _skeletonData$skeFoot4 === void 0 ? void 0 : _skeletonData$skeFoot4.values()) !== null && _skeletonData$skeFoot3 !== void 0 ? _skeletonData$skeFoot3 : (_skeletonData$skeHead3 = skeletonData.skeHeaders.get(segmentId)) === null || _skeletonData$skeHead3 === void 0 ? void 0 : _skeletonData$skeHead3.values();
15318
+ var _skeletonData$skeFoot2, _skeletonData$skeHead2;
15319
+ const page = ((_skeletonData$skeFoot2 = skeletonData.skeFooters.get(segmentId)) === null || _skeletonData$skeFoot2 === void 0 ? void 0 : _skeletonData$skeFoot2.values()) ?? ((_skeletonData$skeHead2 = skeletonData.skeHeaders.get(segmentId)) === null || _skeletonData$skeHead2 === void 0 ? void 0 : _skeletonData$skeHead2.values());
15420
15320
  if (!page) return bounds;
15421
15321
  return calc(Array.from(page));
15422
15322
  }
@@ -15448,8 +15348,8 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15448
15348
  return getListParagraphContextMenuHit(paragraphBound, this._getParagraphByStartIndex(paragraphBound.startIndex, paragraphBound.segmentId), evt);
15449
15349
  }
15450
15350
  _getParagraphByStartIndex(startIndex, segmentId) {
15451
- var _this$_context$unit$g4;
15452
- return (_this$_context$unit$g4 = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) === null || _this$_context$unit$g4 === void 0 || (_this$_context$unit$g4 = _this$_context$unit$g4.getBody()) === null || _this$_context$unit$g4 === void 0 || (_this$_context$unit$g4 = _this$_context$unit$g4.paragraphs) === null || _this$_context$unit$g4 === void 0 ? void 0 : _this$_context$unit$g4.find((paragraph) => paragraph.startIndex === startIndex);
15351
+ var _this$_context$unit$g3;
15352
+ return (_this$_context$unit$g3 = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) === null || _this$_context$unit$g3 === void 0 || (_this$_context$unit$g3 = _this$_context$unit$g3.getBody()) === null || _this$_context$unit$g3 === void 0 || (_this$_context$unit$g3 = _this$_context$unit$g3.paragraphs) === null || _this$_context$unit$g3 === void 0 ? void 0 : _this$_context$unit$g3.find((paragraph) => paragraph.startIndex === startIndex);
15453
15353
  }
15454
15354
  _buildParagraphBoundsBySegment(segmentId) {
15455
15355
  const skeletonData = this._skeleton.getSkeletonData();
@@ -15484,9 +15384,8 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15484
15384
  pageMarginTop: documentOffsetConfig.pageMarginTop,
15485
15385
  unitId: this._context.unitId
15486
15386
  }, (context) => {
15487
- var _lineContextsBySource;
15488
15387
  if (context.source === "table-cell") return;
15489
- const lineContexts = (_lineContextsBySource = lineContextsBySource.get(context.pageIndex)) !== null && _lineContextsBySource !== void 0 ? _lineContextsBySource : [];
15388
+ const lineContexts = lineContextsBySource.get(context.pageIndex) ?? [];
15490
15389
  lineContexts.push(context);
15491
15390
  lineContextsBySource.set(context.pageIndex, lineContexts);
15492
15391
  });
@@ -15511,9 +15410,8 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15511
15410
  tableId
15512
15411
  });
15513
15412
  for (const cellGeometry of tableContext.cells) {
15514
- var _cell$pageWidth, _cell$marginLeft, _cell$marginRight;
15515
15413
  const cell = cellGeometry.cell;
15516
- const cellContentWidth = ((_cell$pageWidth = cell.pageWidth) !== null && _cell$pageWidth !== void 0 ? _cell$pageWidth : 0) - ((_cell$marginLeft = cell.marginLeft) !== null && _cell$marginLeft !== void 0 ? _cell$marginLeft : 0) - ((_cell$marginRight = cell.marginRight) !== null && _cell$marginRight !== void 0 ? _cell$marginRight : 0);
15414
+ const cellContentWidth = (cell.pageWidth ?? 0) - (cell.marginLeft ?? 0) - (cell.marginRight ?? 0);
15517
15415
  const bounds = calcDocParagraphPositions(cell.sections, cellGeometry.pageTop, cellGeometry.pageLeft, cellContentWidth).map((bound) => clipParagraphBoundHorizontally(bound, cellGeometry.clipLeft, cellGeometry.clipRight)).filter((bound) => bound != null);
15518
15416
  let arr = this._tableParagraphBounds.get(tableId);
15519
15417
  if (!arr) {
@@ -15549,15 +15447,15 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15549
15447
  return paragraphMap;
15550
15448
  };
15551
15449
  if (segmentId) {
15552
- var _skeletonData$skeFoot5, _skeletonData$skeFoot6, _skeletonData$skeHead4;
15553
- const page = (_skeletonData$skeFoot5 = (_skeletonData$skeFoot6 = skeletonData.skeFooters.get(segmentId)) === null || _skeletonData$skeFoot6 === void 0 ? void 0 : _skeletonData$skeFoot6.values()) !== null && _skeletonData$skeFoot5 !== void 0 ? _skeletonData$skeFoot5 : (_skeletonData$skeHead4 = skeletonData.skeHeaders.get(segmentId)) === null || _skeletonData$skeHead4 === void 0 ? void 0 : _skeletonData$skeHead4.values();
15450
+ var _skeletonData$skeFoot3, _skeletonData$skeHead3;
15451
+ const page = ((_skeletonData$skeFoot3 = skeletonData.skeFooters.get(segmentId)) === null || _skeletonData$skeFoot3 === void 0 ? void 0 : _skeletonData$skeFoot3.values()) ?? ((_skeletonData$skeHead3 = skeletonData.skeHeaders.get(segmentId)) === null || _skeletonData$skeHead3 === void 0 ? void 0 : _skeletonData$skeHead3.values());
15554
15452
  if (!page) return null;
15555
15453
  return calc(Array.from(page));
15556
15454
  }
15557
15455
  return calc(skeletonData.pages);
15558
15456
  }
15559
15457
  _buildParagraphBounds() {
15560
- var _this$_buildParagraph, _this$_skeleton$getSk3;
15458
+ var _this$_skeleton$getSk3;
15561
15459
  const tableViewportSignature = this._getTableViewportSignature();
15562
15460
  if (!this._paragraphDirty && this._tableViewportSignature === tableViewportSignature) return;
15563
15461
  this._paragraphDirty = false;
@@ -15565,7 +15463,7 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15565
15463
  this._tableParagraphBounds = /* @__PURE__ */ new Map();
15566
15464
  this._tableCellBounds = /* @__PURE__ */ new Map();
15567
15465
  this._tableBounds = /* @__PURE__ */ new Map();
15568
- this._paragraphBounds = (_this$_buildParagraph = this._buildParagraphBoundsBySegment()) !== null && _this$_buildParagraph !== void 0 ? _this$_buildParagraph : /* @__PURE__ */ new Map();
15466
+ this._paragraphBounds = this._buildParagraphBoundsBySegment() ?? /* @__PURE__ */ new Map();
15569
15467
  this._paragraphLeftBounds = Array.from(this._paragraphBounds.values()).map((bound) => ({
15570
15468
  ...bound,
15571
15469
  rect: {
@@ -15576,8 +15474,7 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15576
15474
  }
15577
15475
  }));
15578
15476
  const handleSegment = (segmentId) => {
15579
- var _this$_buildParagraph2;
15580
- this._segmentParagraphBounds.set(segmentId, (_this$_buildParagraph2 = this._buildParagraphBoundsBySegment(segmentId)) !== null && _this$_buildParagraph2 !== void 0 ? _this$_buildParagraph2 : /* @__PURE__ */ new Map());
15477
+ this._segmentParagraphBounds.set(segmentId, this._buildParagraphBoundsBySegment(segmentId) ?? /* @__PURE__ */ new Map());
15581
15478
  };
15582
15479
  (_this$_skeleton$getSk3 = this._skeleton.getSkeletonData()) === null || _this$_skeleton$getSk3 === void 0 || _this$_skeleton$getSk3.pages.forEach((page) => {
15583
15480
  if (page.headerId) handleSegment(page.headerId);
@@ -15642,8 +15539,8 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
15642
15539
  })), startIndex, endIndex);
15643
15540
  }
15644
15541
  _getTableViewportSignature() {
15645
- var _this$_skeleton$getSk4, _this$_skeleton$getSk5;
15646
- const pages = (_this$_skeleton$getSk4 = (_this$_skeleton$getSk5 = this._skeleton.getSkeletonData()) === null || _this$_skeleton$getSk5 === void 0 ? void 0 : _this$_skeleton$getSk5.pages) !== null && _this$_skeleton$getSk4 !== void 0 ? _this$_skeleton$getSk4 : [];
15542
+ var _this$_skeleton$getSk4;
15543
+ const pages = ((_this$_skeleton$getSk4 = this._skeleton.getSkeletonData()) === null || _this$_skeleton$getSk4 === void 0 ? void 0 : _this$_skeleton$getSk4.pages) ?? [];
15647
15544
  const signatures = [];
15648
15545
  for (const tableContext of documentSkeletonTableIterator(pages, {
15649
15546
  pageMarginTop: this._documents.getOffsetConfig().pageMarginTop,
@@ -15671,13 +15568,12 @@ function isRangeOverlappingParagraph(bound, startIndex, endIndex) {
15671
15568
  return Math.max(bound.paragraphStart, startIndex) <= Math.min(bound.paragraphEnd, endIndex);
15672
15569
  }
15673
15570
  function clipParagraphBoundHorizontally(bound, visibleLeft, visibleRight) {
15674
- var _clipRectHorizontally;
15675
15571
  const rect = clipRectHorizontally(bound.rect, visibleLeft, visibleRight);
15676
15572
  if (!rect) return null;
15677
15573
  return {
15678
15574
  ...bound,
15679
15575
  rect,
15680
- fisrtLine: (_clipRectHorizontally = clipRectHorizontally(bound.fisrtLine, visibleLeft, visibleRight)) !== null && _clipRectHorizontally !== void 0 ? _clipRectHorizontally : rect
15576
+ fisrtLine: clipRectHorizontally(bound.fisrtLine, visibleLeft, visibleRight) ?? rect
15681
15577
  };
15682
15578
  }
15683
15579
  function clipRectHorizontally(rect, visibleLeft, visibleRight) {
@@ -15733,7 +15629,7 @@ const SideMenu = forwardRef((props, ref) => {
15733
15629
  transform: open ? "translateX(0)" : "translateX(-100%)",
15734
15630
  maxHeight,
15735
15631
  opacity: open ? 1 : 0,
15736
- maxWidth: maxWidth !== null && maxWidth !== void 0 ? maxWidth : mode === "side-bar" ? 320 : 180,
15632
+ maxWidth: maxWidth ?? (mode === "side-bar" ? 320 : 180),
15737
15633
  paddingRight: mode === "float" ? void 0 : 0
15738
15634
  },
15739
15635
  children: /* @__PURE__ */ jsx("div", {
@@ -15798,28 +15694,28 @@ function DocSideMenu() {
15798
15694
  return null;
15799
15695
  }
15800
15696
  function DocSideMenuContent() {
15801
- var _documentData$body$da, _documentData$body, _currentDoc$getUnitId, _documentData$body$pa, _documentData$body2;
15697
+ var _documentData$body, _documentData$body2;
15802
15698
  const instanceService = useDependency(IUniverInstanceService);
15803
15699
  const currentDoc = useObservable(useMemo(() => instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), []));
15804
15700
  const renderManagerService = useDependency(IRenderManagerService);
15805
15701
  const documentData = useObservable(currentDoc ? () => currentDoc.change$.pipe(debounceTime(100), map(() => currentDoc.getSnapshot())) : null, currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getSnapshot(), false, [currentDoc]);
15806
- 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 : "";
15702
+ const fullDataStream = (documentData === null || documentData === void 0 || (_documentData$body = documentData.body) === null || _documentData$body === void 0 ? void 0 : _documentData$body.dataStream) ?? "";
15807
15703
  const [activeId, setActiveId] = useState(void 0);
15808
- const unitId = (_currentDoc$getUnitId = currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getUnitId()) !== null && _currentDoc$getUnitId !== void 0 ? _currentDoc$getUnitId : "";
15704
+ const unitId = (currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getUnitId()) ?? "";
15809
15705
  const renderer = renderManagerService.getRenderUnitById(unitId);
15810
15706
  const title = documentData === null || documentData === void 0 ? void 0 : documentData.title;
15811
15707
  const docEventManagerService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocEventManagerService);
15812
15708
  const paragraphBounds = docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.paragraphBounds;
15813
15709
  const readLayout = () => {
15814
- var _renderer$mainCompone, _renderer$mainCompone2, _renderer$engine$heig, _renderer$scene$scale;
15710
+ var _renderer$mainCompone;
15815
15711
  return {
15816
- left: (_renderer$mainCompone = renderer === null || renderer === void 0 || (_renderer$mainCompone2 = renderer.mainComponent) === null || _renderer$mainCompone2 === void 0 ? void 0 : _renderer$mainCompone2.left) !== null && _renderer$mainCompone !== void 0 ? _renderer$mainCompone : 0,
15817
- canvasHeight: (_renderer$engine$heig = renderer === null || renderer === void 0 ? void 0 : renderer.engine.height) !== null && _renderer$engine$heig !== void 0 ? _renderer$engine$heig : 0,
15818
- scaleY: (_renderer$scene$scale = renderer === null || renderer === void 0 ? void 0 : renderer.scene.scaleY) !== null && _renderer$scene$scale !== void 0 ? _renderer$scene$scale : 1
15712
+ left: (renderer === null || renderer === void 0 || (_renderer$mainCompone = renderer.mainComponent) === null || _renderer$mainCompone === void 0 ? void 0 : _renderer$mainCompone.left) ?? 0,
15713
+ canvasHeight: (renderer === null || renderer === void 0 ? void 0 : renderer.engine.height) ?? 0,
15714
+ scaleY: (renderer === null || renderer === void 0 ? void 0 : renderer.scene.scaleY) ?? 1
15819
15715
  };
15820
15716
  };
15821
15717
  const { left, canvasHeight, scaleY } = useObservable((renderer === null || renderer === void 0 ? void 0 : renderer.engine.onTransformChange$) ? () => fromEventSubject(renderer.engine.onTransformChange$).pipe(throttleTime(33), map(readLayout), startWith(readLayout())) : null, readLayout(), false, [renderer]);
15822
- const paragraphs = (_documentData$body$pa = documentData === null || documentData === void 0 || (_documentData$body2 = documentData.body) === null || _documentData$body2 === void 0 ? void 0 : _documentData$body2.paragraphs) !== null && _documentData$body$pa !== void 0 ? _documentData$body$pa : [];
15718
+ const paragraphs = (documentData === null || documentData === void 0 || (_documentData$body2 = documentData.body) === null || _documentData$body2 === void 0 ? void 0 : _documentData$body2.paragraphs) ?? [];
15823
15719
  const paragraphMap = useMemo(() => {
15824
15720
  const map = /* @__PURE__ */ new Map();
15825
15721
  paragraphs.forEach((p) => {
@@ -15857,7 +15753,7 @@ function DocSideMenuContent() {
15857
15753
  text: title,
15858
15754
  level: 1,
15859
15755
  isTitle: true
15860
- }] : [], ...paragraphMenus !== null && paragraphMenus !== void 0 ? paragraphMenus : []].filter(Boolean);
15756
+ }] : [], ...paragraphMenus ?? []].filter(Boolean);
15861
15757
  const [open, setOpen] = useState(true);
15862
15758
  useEffect(() => {
15863
15759
  const viewport = renderer === null || renderer === void 0 ? void 0 : renderer.scene.getViewport("viewMain");
@@ -16035,12 +15931,22 @@ function createDefaultDocsTableLikeCustomBlockBleedViewport() {
16035
15931
  }
16036
15932
  function resolveDocsTableLikeCustomBlockBleedViewport(root, contentWidth, hint) {
16037
15933
  const rootRect = root.getBoundingClientRect();
16038
- const rootWidth = Math.max(1, rootRect.width);
15934
+ const hintedViewScale = hint === null || hint === void 0 ? void 0 : hint.viewScale;
15935
+ const viewScale = typeof hintedViewScale === "number" && Number.isFinite(hintedViewScale) && hintedViewScale > 0 ? hintedViewScale : 1;
15936
+ const rootWidth = Math.max(1, rootRect.width / viewScale);
16039
15937
  const normalizedContentWidth = Math.max(1, contentWidth);
16040
15938
  const hintedBleedLeft = hint === null || hint === void 0 ? void 0 : hint.bleedLeft;
16041
15939
  const hintedBleedWidth = hint === null || hint === void 0 ? void 0 : hint.bleedWidth;
16042
- if (Number.isFinite(hintedBleedWidth) && (hintedBleedWidth !== null && hintedBleedWidth !== void 0 ? hintedBleedWidth : 0) > 0) {
16043
- const bleedLeft = Math.max(0, hintedBleedLeft !== null && hintedBleedLeft !== void 0 ? hintedBleedLeft : 0);
15940
+ const hasBleedHint = Number.isFinite(hintedBleedWidth) && (hintedBleedWidth ?? 0) > 0;
15941
+ if (normalizedContentWidth <= rootWidth && ((hint === null || hint === void 0 ? void 0 : hint.authoritativeContentWidth) || !hasBleedHint)) return {
15942
+ bleedLeft: 0,
15943
+ bleedRight: 0,
15944
+ bleedWidth: rootWidth,
15945
+ contentWidth: normalizedContentWidth,
15946
+ virtualWidth: rootWidth
15947
+ };
15948
+ if (hasBleedHint) {
15949
+ const bleedLeft = Math.max(0, hintedBleedLeft ?? 0);
16044
15950
  const bleedWidth = Math.max(1, hintedBleedWidth);
16045
15951
  return {
16046
15952
  bleedLeft,
@@ -16050,30 +15956,25 @@ function resolveDocsTableLikeCustomBlockBleedViewport(root, contentWidth, hint)
16050
15956
  virtualWidth: Math.max(bleedWidth, bleedLeft + normalizedContentWidth)
16051
15957
  };
16052
15958
  }
16053
- if (normalizedContentWidth <= rootWidth) return {
16054
- bleedLeft: 0,
16055
- bleedRight: 0,
16056
- bleedWidth: rootWidth,
16057
- contentWidth: normalizedContentWidth,
16058
- virtualWidth: rootWidth
16059
- };
16060
15959
  const bounds = resolveDocsTableLikeCustomBlockBleedBounds(root);
16061
15960
  const viewportLeft = bounds.left + DOCS_CUSTOM_BLOCK_VIEWPORT_INSET;
16062
15961
  const viewportWidth = Math.max(1, bounds.width - DOCS_CUSTOM_BLOCK_VIEWPORT_INSET * 2);
16063
- const bleedLeft = Math.max(0, rootRect.left - viewportLeft);
15962
+ const bleedLeft = Math.max(0, (rootRect.left - viewportLeft) / viewScale);
15963
+ const bleedRight = Math.max(0, (viewportLeft + viewportWidth - rootRect.right) / viewScale);
15964
+ const logicalViewportWidth = viewportWidth / viewScale;
16064
15965
  return {
16065
15966
  bleedLeft,
16066
- bleedRight: Math.max(0, viewportLeft + viewportWidth - rootRect.right),
16067
- bleedWidth: viewportWidth,
15967
+ bleedRight,
15968
+ bleedWidth: logicalViewportWidth,
16068
15969
  contentWidth: normalizedContentWidth,
16069
- virtualWidth: Math.max(viewportWidth, bleedLeft + normalizedContentWidth)
15970
+ virtualWidth: Math.max(logicalViewportWidth, bleedLeft + normalizedContentWidth)
16070
15971
  };
16071
15972
  }
16072
15973
  function resolveDocsTableLikeCustomBlockContentWidth(authoritativeContentWidth, fallbackContentWidth) {
16073
- return Number.isFinite(authoritativeContentWidth) && (authoritativeContentWidth !== null && authoritativeContentWidth !== void 0 ? authoritativeContentWidth : 0) > 0 ? authoritativeContentWidth : Math.max(1, fallbackContentWidth);
15974
+ return Number.isFinite(authoritativeContentWidth) && (authoritativeContentWidth ?? 0) > 0 ? authoritativeContentWidth : Math.max(1, fallbackContentWidth);
16074
15975
  }
16075
15976
  function resolveDocsTableLikeCustomBlockContentHeight(authoritativeContentHeight, fallbackContentHeight) {
16076
- return Number.isFinite(authoritativeContentHeight) && (authoritativeContentHeight !== null && authoritativeContentHeight !== void 0 ? authoritativeContentHeight : 0) > 0 ? authoritativeContentHeight : Math.max(1, fallbackContentHeight);
15977
+ return Number.isFinite(authoritativeContentHeight) && (authoritativeContentHeight ?? 0) > 0 ? authoritativeContentHeight : Math.max(1, fallbackContentHeight);
16077
15978
  }
16078
15979
  function resolveDocsTableLikeCustomBlockBleedBounds(root) {
16079
15980
  const clippingAncestor = findClippingAncestor(root);
@@ -16109,10 +16010,9 @@ function hasClippingOverflow(value) {
16109
16010
  //#region src/embed-docs-custom-block-refresh.ts
16110
16011
  function collectDocsTableLikeEmbedChildUnitIds(drawings, resolveChildUnitId) {
16111
16012
  const childUnitIds = /* @__PURE__ */ new Set();
16112
- Object.values(drawings !== null && drawings !== void 0 ? drawings : {}).forEach((drawing) => {
16113
- var _resolveChildUnitId;
16013
+ Object.values(drawings ?? {}).forEach((drawing) => {
16114
16014
  const data = getDrawingData(drawing);
16115
- const childUnitId = data ? (_resolveChildUnitId = resolveChildUnitId === null || resolveChildUnitId === void 0 ? void 0 : resolveChildUnitId(data)) !== null && _resolveChildUnitId !== void 0 ? _resolveChildUnitId : typeof data.childUnitId === "string" ? data.childUnitId : void 0 : void 0;
16015
+ const childUnitId = data ? (resolveChildUnitId === null || resolveChildUnitId === void 0 ? void 0 : resolveChildUnitId(data)) ?? (typeof data.childUnitId === "string" ? data.childUnitId : void 0) : void 0;
16116
16016
  const childType = typeof (data === null || data === void 0 ? void 0 : data.childType) === "number" ? data.childType : void 0;
16117
16017
  if (!childUnitId || !isSheetLikeDocsCustomBlockChildType(childType)) return;
16118
16018
  childUnitIds.add(childUnitId);
@@ -16195,31 +16095,31 @@ function clampScroll(value, min, max) {
16195
16095
  function resolveMaxScrollLeft(element, requestedMaxScrollLeft) {
16196
16096
  const nativeMaxScrollLeft = Math.max(0, element.scrollWidth - element.clientWidth);
16197
16097
  if (!Number.isFinite(requestedMaxScrollLeft)) return nativeMaxScrollLeft;
16198
- return clampScroll(requestedMaxScrollLeft !== null && requestedMaxScrollLeft !== void 0 ? requestedMaxScrollLeft : nativeMaxScrollLeft, 0, nativeMaxScrollLeft);
16098
+ return clampScroll(requestedMaxScrollLeft ?? nativeMaxScrollLeft, 0, nativeMaxScrollLeft);
16199
16099
  }
16200
16100
 
16201
16101
  //#endregion
16202
16102
  //#region src/embed-host-anchor.ts
16203
16103
  const MODERN_DOCS_CUSTOM_BLOCK_VIEWPORT_INSET = 10;
16204
16104
  function resolveDocsCustomBlockRenderViewport(params) {
16205
- var _params$fallbackWidth, _params$fallbackHeigh, _params$contentHeight, _params$visibleCanvas, _params$pageMarginLef, _params$pageMarginRig, _params$contentWidth, _params$docsLeft, _params$visibleCanvas2;
16206
16105
  const defaultSize = resolveDocsCustomBlockSize(params.childType);
16207
- const fallbackWidth = (_params$fallbackWidth = params.fallbackWidth) !== null && _params$fallbackWidth !== void 0 ? _params$fallbackWidth : defaultSize.width;
16208
- const fallbackHeight = (_params$fallbackHeigh = params.fallbackHeight) !== null && _params$fallbackHeigh !== void 0 ? _params$fallbackHeigh : defaultSize.height;
16106
+ const fallbackWidth = params.fallbackWidth ?? defaultSize.width;
16107
+ const fallbackHeight = params.fallbackHeight ?? defaultSize.height;
16209
16108
  const sheetLike = isSheetLikeDocsCustomBlockChildType(params.childType);
16210
- const contentHeight = Number.isFinite(params.contentHeight) && ((_params$contentHeight = params.contentHeight) !== null && _params$contentHeight !== void 0 ? _params$contentHeight : 0) > 0 ? params.contentHeight : fallbackHeight;
16211
- const visibleCanvasHeight = Number.isFinite(params.visibleCanvasHeight) && ((_params$visibleCanvas = params.visibleCanvasHeight) !== null && _params$visibleCanvas !== void 0 ? _params$visibleCanvas : 0) > 0 ? params.visibleCanvasHeight : void 0;
16109
+ const contentHeight = Number.isFinite(params.contentHeight) && (params.contentHeight ?? 0) > 0 ? params.contentHeight : fallbackHeight;
16110
+ const visibleCanvasHeight = Number.isFinite(params.visibleCanvasHeight) && (params.visibleCanvasHeight ?? 0) > 0 ? params.visibleCanvasHeight : void 0;
16212
16111
  const height = sheetLike ? contentHeight : fallbackHeight;
16213
16112
  const viewportHeight = sheetLike && visibleCanvasHeight != null ? Math.min(contentHeight, visibleCanvasHeight) : height;
16113
+ const viewScale = params.scale && params.scale > 0 ? params.scale : 1;
16214
16114
  if (!sheetLike) return {
16215
16115
  height,
16216
16116
  width: fallbackWidth
16217
16117
  };
16218
16118
  const pageWidth = params.pageWidth;
16219
- const pageMarginLeft = (_params$pageMarginLef = params.pageMarginLeft) !== null && _params$pageMarginLef !== void 0 ? _params$pageMarginLef : 0;
16220
- const pageMarginRight = (_params$pageMarginRig = params.pageMarginRight) !== null && _params$pageMarginRig !== void 0 ? _params$pageMarginRig : 0;
16119
+ const pageMarginLeft = params.pageMarginLeft ?? 0;
16120
+ const pageMarginRight = params.pageMarginRight ?? 0;
16221
16121
  const pageContentWidth = Number.isFinite(pageWidth) ? Math.max(0, pageWidth - pageMarginLeft - pageMarginRight) : fallbackWidth;
16222
- const contentWidth = Number.isFinite(params.contentWidth) && ((_params$contentWidth = params.contentWidth) !== null && _params$contentWidth !== void 0 ? _params$contentWidth : 0) > 0 ? params.contentWidth : fallbackWidth;
16122
+ const contentWidth = Number.isFinite(params.contentWidth) && (params.contentWidth ?? 0) > 0 ? params.contentWidth : fallbackWidth;
16223
16123
  if (params.documentFlavor !== DocumentFlavor.MODERN || !Number.isFinite(pageWidth)) {
16224
16124
  const layoutWidth = Math.min(contentWidth, pageContentWidth || contentWidth);
16225
16125
  return {
@@ -16228,16 +16128,17 @@ function resolveDocsCustomBlockRenderViewport(params) {
16228
16128
  height,
16229
16129
  layoutWidth,
16230
16130
  offsetLeft: 0,
16131
+ pageContentWidth,
16132
+ viewScale,
16231
16133
  viewportHeight,
16232
16134
  width: layoutWidth
16233
16135
  };
16234
16136
  }
16235
- const scale = params.scale && params.scale > 0 ? params.scale : 1;
16236
- const inset = MODERN_DOCS_CUSTOM_BLOCK_VIEWPORT_INSET / scale;
16237
- const docsLeft = (_params$docsLeft = params.docsLeft) !== null && _params$docsLeft !== void 0 ? _params$docsLeft : 0;
16137
+ const inset = MODERN_DOCS_CUSTOM_BLOCK_VIEWPORT_INSET / viewScale;
16138
+ const docsLeft = params.docsLeft ?? 0;
16238
16139
  const fallbackViewportLeft = docsLeft + inset;
16239
16140
  const fallbackViewportWidth = Math.max(0, pageWidth - inset * 2);
16240
- const hasVisibleCanvas = Number.isFinite(params.visibleCanvasLeft) && Number.isFinite(params.visibleCanvasWidth) && ((_params$visibleCanvas2 = params.visibleCanvasWidth) !== null && _params$visibleCanvas2 !== void 0 ? _params$visibleCanvas2 : 0) > 0;
16141
+ const hasVisibleCanvas = Number.isFinite(params.visibleCanvasLeft) && Number.isFinite(params.visibleCanvasWidth) && (params.visibleCanvasWidth ?? 0) > 0;
16241
16142
  const viewportLeft = hasVisibleCanvas ? params.visibleCanvasLeft + inset : fallbackViewportLeft;
16242
16143
  const viewportWidth = hasVisibleCanvas ? Math.max(0, params.visibleCanvasWidth - inset * 2) : fallbackViewportWidth;
16243
16144
  const paragraphTextStart = docsLeft + pageMarginLeft;
@@ -16251,6 +16152,8 @@ function resolveDocsCustomBlockRenderViewport(params) {
16251
16152
  height,
16252
16153
  layoutWidth,
16253
16154
  offsetLeft: 0,
16155
+ pageContentWidth,
16156
+ viewScale,
16254
16157
  viewportHeight,
16255
16158
  width: layoutWidth
16256
16159
  };
@@ -16259,7 +16162,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
16259
16162
  //#endregion
16260
16163
  //#region package.json
16261
16164
  var name = "@univerjs/docs-ui";
16262
- var version = "1.0.0-alpha.8";
16165
+ var version = "1.0.0-beta.0";
16263
16166
 
16264
16167
  //#endregion
16265
16168
  //#region src/commands/commands/doc-paragraph-setting.command.ts
@@ -16267,7 +16170,6 @@ const DocParagraphSettingCommand = {
16267
16170
  id: "doc-paragraph-setting.command",
16268
16171
  type: CommandType.COMMAND,
16269
16172
  handler: async (accessor, config) => {
16270
- var _segmentBody$paragrap, _segmentBody$dataStre, _BuildTextUtils$range;
16271
16173
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
16272
16174
  const univerInstanceService = accessor.get(IUniverInstanceService);
16273
16175
  const commandService = accessor.get(ICommandService);
@@ -16278,9 +16180,9 @@ const DocParagraphSettingCommand = {
16278
16180
  const unitId = docDataModel.getUnitId();
16279
16181
  const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
16280
16182
  const segmentBody = segment === null || segment === void 0 ? void 0 : segment.getBody();
16281
- const allParagraphs = (_segmentBody$paragrap = segmentBody === null || segmentBody === void 0 ? void 0 : segmentBody.paragraphs) !== null && _segmentBody$paragrap !== void 0 ? _segmentBody$paragrap : [];
16282
- const dataStream = (_segmentBody$dataStre = segmentBody === null || segmentBody === void 0 ? void 0 : segmentBody.dataStream) !== null && _segmentBody$dataStre !== void 0 ? _segmentBody$dataStre : "";
16283
- const paragraphs = (_BuildTextUtils$range = BuildTextUtils.range.getParagraphsInRanges(docRanges, allParagraphs, dataStream)) !== null && _BuildTextUtils$range !== void 0 ? _BuildTextUtils$range : [];
16183
+ const allParagraphs = (segmentBody === null || segmentBody === void 0 ? void 0 : segmentBody.paragraphs) ?? [];
16184
+ const dataStream = (segmentBody === null || segmentBody === void 0 ? void 0 : segmentBody.dataStream) ?? "";
16185
+ const paragraphs = BuildTextUtils.range.getParagraphsInRanges(docRanges, allParagraphs, dataStream) ?? [];
16284
16186
  const doMutation = {
16285
16187
  id: RichTextEditingMutation.id,
16286
16188
  params: {
@@ -16430,16 +16332,15 @@ function getSegmentId(documentStyle, editArea, pageIndex, page) {
16430
16332
  else return evenAndOddHeaders === BooleanNumber.TRUE && isEvenPage ? evenPageFooterId : defaultFooterId;
16431
16333
  }
16432
16334
  const DocHeaderFooterOptions = (props) => {
16433
- var _segmentContext$segme, _segmentContext$segme2;
16434
16335
  const docSelectionRenderService = useDependency(IRenderManagerService).getRenderUnitById(props.unitId).with(DocSelectionRenderService);
16435
16336
  const segmentContext = useObservable(docSelectionRenderService.segmentContext$, {
16436
16337
  segmentId: docSelectionRenderService.getSegment(),
16437
16338
  segmentPage: docSelectionRenderService.getSegmentPage()
16438
16339
  });
16439
- return /* @__PURE__ */ jsx(DocHeaderFooterOptionsContent, { ...props }, `${(_segmentContext$segme = segmentContext === null || segmentContext === void 0 ? void 0 : segmentContext.segmentId) !== null && _segmentContext$segme !== void 0 ? _segmentContext$segme : ""}:${(_segmentContext$segme2 = segmentContext === null || segmentContext === void 0 ? void 0 : segmentContext.segmentPage) !== null && _segmentContext$segme2 !== void 0 ? _segmentContext$segme2 : -1}`);
16340
+ return /* @__PURE__ */ jsx(DocHeaderFooterOptionsContent, { ...props }, `${(segmentContext === null || segmentContext === void 0 ? void 0 : segmentContext.segmentId) ?? ""}:${(segmentContext === null || segmentContext === void 0 ? void 0 : segmentContext.segmentPage) ?? -1}`);
16440
16341
  };
16441
16342
  function DocHeaderFooterOptionsContent(props) {
16442
- var _renderManagerService2, _sectionContext$confi, _sectionContext$secti, _sectionContext$secti2;
16343
+ var _renderManagerService2, _sectionContext$secti;
16443
16344
  const localeService = useDependency(LocaleService);
16444
16345
  const univerInstanceService = useDependency(IUniverInstanceService);
16445
16346
  const renderManagerService = useDependency(IRenderManagerService);
@@ -16459,19 +16360,19 @@ function DocHeaderFooterOptionsContent(props) {
16459
16360
  };
16460
16361
  };
16461
16362
  const [options, setOptions] = useState(() => {
16462
- var _getCurrentSectionCon, _config$marginHeader, _config$marginFooter, _config$useFirstPageH, _config$evenAndOddHea;
16363
+ var _getCurrentSectionCon;
16463
16364
  const config = (_getCurrentSectionCon = getCurrentSectionContext()) === null || _getCurrentSectionCon === void 0 ? void 0 : _getCurrentSectionCon.config;
16464
16365
  return {
16465
- marginHeader: (_config$marginHeader = config === null || config === void 0 ? void 0 : config.marginHeader) !== null && _config$marginHeader !== void 0 ? _config$marginHeader : 0,
16466
- marginFooter: (_config$marginFooter = config === null || config === void 0 ? void 0 : config.marginFooter) !== null && _config$marginFooter !== void 0 ? _config$marginFooter : 0,
16467
- useFirstPageHeaderFooter: (_config$useFirstPageH = config === null || config === void 0 ? void 0 : config.useFirstPageHeaderFooter) !== null && _config$useFirstPageH !== void 0 ? _config$useFirstPageH : BooleanNumber.FALSE,
16468
- evenAndOddHeaders: (_config$evenAndOddHea = config === null || config === void 0 ? void 0 : config.evenAndOddHeaders) !== null && _config$evenAndOddHea !== void 0 ? _config$evenAndOddHea : BooleanNumber.FALSE
16366
+ marginHeader: (config === null || config === void 0 ? void 0 : config.marginHeader) ?? 0,
16367
+ marginFooter: (config === null || config === void 0 ? void 0 : config.marginFooter) ?? 0,
16368
+ useFirstPageHeaderFooter: (config === null || config === void 0 ? void 0 : config.useFirstPageHeaderFooter) ?? BooleanNumber.FALSE,
16369
+ evenAndOddHeaders: (config === null || config === void 0 ? void 0 : config.evenAndOddHeaders) ?? BooleanNumber.FALSE
16469
16370
  };
16470
16371
  });
16471
16372
  const sectionContext = getCurrentSectionContext();
16472
- const referenceKey = getSectionHeaderFooterReferenceKey(((_renderManagerService2 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.with(DocSkeletonManagerService)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.getViewModel()) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.getEditArea()) === 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));
16473
- const canLinkToPrevious = ((_sectionContext$secti = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionIndex) !== null && _sectionContext$secti !== void 0 ? _sectionContext$secti : -1) > 0;
16474
- const [linkedToPrevious, setLinkedToPrevious] = useState(canLinkToPrevious && !(sectionContext === null || sectionContext === void 0 || (_sectionContext$secti2 = sectionContext.section) === null || _sectionContext$secti2 === void 0 ? void 0 : _sectionContext$secti2[referenceKey]));
16373
+ const referenceKey = getSectionHeaderFooterReferenceKey(((_renderManagerService2 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.with(DocSkeletonManagerService)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.getViewModel()) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.getEditArea()) === DocumentEditArea.FOOTER ? "footer" : "header", getHeaderFooterVariant((sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config) ?? {}, docSelectionRenderService.getSegmentPage(), sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page));
16374
+ const canLinkToPrevious = ((sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionIndex) ?? -1) > 0;
16375
+ const [linkedToPrevious, setLinkedToPrevious] = useState(canLinkToPrevious && !(sectionContext === null || sectionContext === void 0 || (_sectionContext$secti = sectionContext.section) === null || _sectionContext$secti === void 0 ? void 0 : _sectionContext$secti[referenceKey]));
16475
16376
  const handleCheckboxChange = (val, type) => {
16476
16377
  var _renderManagerService3;
16477
16378
  setOptions((prev) => ({
@@ -16559,7 +16460,7 @@ function DocHeaderFooterOptionsContent(props) {
16559
16460
  ...linked ? {} : { segmentId }
16560
16461
  })) return;
16561
16462
  setLinkedToPrevious(linked);
16562
- docSelectionRenderService.setSegment(linked ? previousSegmentId !== null && previousSegmentId !== void 0 ? previousSegmentId : "" : segmentId);
16463
+ docSelectionRenderService.setSegment(linked ? previousSegmentId ?? "" : segmentId);
16563
16464
  layoutService.focus();
16564
16465
  };
16565
16466
  return /* @__PURE__ */ jsxs("div", {
@@ -16701,21 +16602,22 @@ function TextColorSwatchIcon({ className, style, onClick, color }) {
16701
16602
  "aria-hidden": "true",
16702
16603
  onClick,
16703
16604
  children: [/* @__PURE__ */ jsx("rect", {
16704
- x: 3,
16705
- y: 3,
16706
- width: 18,
16707
- height: 18,
16708
- rx: 4,
16605
+ x: 1,
16606
+ y: 1,
16607
+ width: 22,
16608
+ height: 22,
16609
+ rx: 2.5,
16709
16610
  fill: "none",
16710
16611
  stroke: "currentColor",
16711
- strokeOpacity: .16
16612
+ strokeWidth: 1,
16613
+ strokeOpacity: .12
16712
16614
  }), /* @__PURE__ */ jsx("text", {
16713
16615
  x: 12,
16714
- y: 16.5,
16616
+ y: 17.25,
16715
16617
  direction: "ltr",
16716
16618
  fontFamily: "Arial, sans-serif",
16717
- fontSize: 12,
16718
- fontWeight: 700,
16619
+ fontSize: 15,
16620
+ fontWeight: 400,
16719
16621
  fill: color,
16720
16622
  textAnchor: "middle",
16721
16623
  children: "A"
@@ -16737,7 +16639,7 @@ function BackgroundColorSwatchIcon({ className, style, onClick, color }) {
16737
16639
  y: 3,
16738
16640
  width: 18,
16739
16641
  height: 18,
16740
- rx: 5,
16642
+ rx: 3,
16741
16643
  fill: color,
16742
16644
  stroke: "currentColor",
16743
16645
  strokeOpacity: .12
@@ -16745,12 +16647,11 @@ function BackgroundColorSwatchIcon({ className, style, onClick, color }) {
16745
16647
  });
16746
16648
  }
16747
16649
  function HeaderTextColorIcon({ className, style, onClick, extend }) {
16748
- var _extend$colorChannel;
16749
16650
  return /* @__PURE__ */ jsx(TextColorSwatchIcon, {
16750
16651
  className,
16751
16652
  style,
16752
16653
  onClick,
16753
- color: (_extend$colorChannel = extend === null || extend === void 0 ? void 0 : extend.colorChannel1) !== null && _extend$colorChannel !== void 0 ? _extend$colorChannel : "currentColor"
16654
+ color: (extend === null || extend === void 0 ? void 0 : extend.colorChannel1) ?? "currentColor"
16754
16655
  });
16755
16656
  }
16756
16657
  function DefaultTextColorIcon({ className, style, onClick }) {
@@ -16865,19 +16766,15 @@ function convertDisplayLineSpacingToStoredValue(lineSpacing, spacingRule) {
16865
16766
  return spacingRule === SpacingRule.AUTO ? lineSpacing : round(lineSpacing, 4);
16866
16767
  }
16867
16768
  function getLineSpacingMetrics(lineNode) {
16868
- var _lineNode$divides, _lineNode$paddingTop, _lineNode$contentHeig, _lineNode$paddingBott;
16869
16769
  if (!lineNode) return null;
16870
- const glyphLineHeight = Math.max(0, ...((_lineNode$divides = lineNode.divides) !== null && _lineNode$divides !== void 0 ? _lineNode$divides : []).flatMap((divide) => {
16871
- var _divide$glyphGroup;
16872
- return ((_divide$glyphGroup = divide.glyphGroup) !== null && _divide$glyphGroup !== void 0 ? _divide$glyphGroup : []).map((glyph) => {
16873
- var _glyph$bBox$ba, _glyph$bBox, _glyph$bBox$bd, _glyph$bBox2;
16874
- return ((_glyph$bBox$ba = (_glyph$bBox = glyph.bBox) === null || _glyph$bBox === void 0 ? void 0 : _glyph$bBox.ba) !== null && _glyph$bBox$ba !== void 0 ? _glyph$bBox$ba : 0) + ((_glyph$bBox$bd = (_glyph$bBox2 = glyph.bBox) === null || _glyph$bBox2 === void 0 ? void 0 : _glyph$bBox2.bd) !== null && _glyph$bBox$bd !== void 0 ? _glyph$bBox$bd : 0);
16875
- });
16876
- })) || lineNode.contentHeight || 0;
16770
+ const glyphLineHeight = Math.max(0, ...(lineNode.divides ?? []).flatMap((divide) => (divide.glyphGroup ?? []).map((glyph) => {
16771
+ var _glyph$bBox, _glyph$bBox2;
16772
+ return (((_glyph$bBox = glyph.bBox) === null || _glyph$bBox === void 0 ? void 0 : _glyph$bBox.ba) ?? 0) + (((_glyph$bBox2 = glyph.bBox) === null || _glyph$bBox2 === void 0 ? void 0 : _glyph$bBox2.bd) ?? 0);
16773
+ }))) || lineNode.contentHeight || 0;
16877
16774
  if (!glyphLineHeight) return null;
16878
16775
  return {
16879
16776
  glyphLineHeight,
16880
- renderedLineHeight: ((_lineNode$paddingTop = lineNode.paddingTop) !== null && _lineNode$paddingTop !== void 0 ? _lineNode$paddingTop : 0) + ((_lineNode$contentHeig = lineNode.contentHeight) !== null && _lineNode$contentHeig !== void 0 ? _lineNode$contentHeig : glyphLineHeight) + ((_lineNode$paddingBott = lineNode.paddingBottom) !== null && _lineNode$paddingBott !== void 0 ? _lineNode$paddingBott : 0) || glyphLineHeight
16777
+ renderedLineHeight: (lineNode.paddingTop ?? 0) + (lineNode.contentHeight ?? glyphLineHeight) + (lineNode.paddingBottom ?? 0) || glyphLineHeight
16881
16778
  };
16882
16779
  }
16883
16780
  function convertLineSpacingForRuleChange(currentStoredValue, currentRule, nextRule, metrics) {
@@ -16899,8 +16796,8 @@ const PARAGRAPH_LAYOUT_BLOCK_TYPES = /* @__PURE__ */ new Set([
16899
16796
  ]);
16900
16797
  function resolveParagraphsForSettingPanel(paragraphs, body, documentStyle) {
16901
16798
  return paragraphs.map((paragraph) => {
16902
- var _body$blockRanges$som, _body$blockRanges;
16903
- const hasLayoutBlockRange = (_body$blockRanges$som = (_body$blockRanges = body.blockRanges) === null || _body$blockRanges === void 0 ? void 0 : _body$blockRanges.some((range) => PARAGRAPH_LAYOUT_BLOCK_TYPES.has(range.blockType) && paragraph.startIndex > range.startIndex && paragraph.startIndex < range.endIndex)) !== null && _body$blockRanges$som !== void 0 ? _body$blockRanges$som : false;
16799
+ var _body$blockRanges;
16800
+ const hasLayoutBlockRange = ((_body$blockRanges = body.blockRanges) === null || _body$blockRanges === void 0 ? void 0 : _body$blockRanges.some((range) => PARAGRAPH_LAYOUT_BLOCK_TYPES.has(range.blockType) && paragraph.startIndex > range.startIndex && paragraph.startIndex < range.endIndex)) ?? false;
16904
16801
  return {
16905
16802
  ...paragraph,
16906
16803
  paragraphStyle: resolveDocumentParagraphStyle(documentStyle, paragraph.paragraphStyle, { excludeDocumentOuterSpacing: hasLayoutBlockRange })
@@ -16917,25 +16814,24 @@ const useDocRanges = () => {
16917
16814
  return docRanges;
16918
16815
  };
16919
16816
  const useCurrentParagraph = () => {
16920
- var _body$paragraphs, _body$dataStream, _BuildTextUtils$range;
16921
16817
  const docDataModel = useDependency(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
16922
16818
  const docRanges = useDocRanges();
16923
16819
  if (!docDataModel || docRanges.length === 0) return [];
16924
16820
  const segmentId = docRanges[0].segmentId;
16925
16821
  const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
16926
16822
  const body = segment === null || segment === void 0 ? void 0 : segment.getBody();
16927
- const paragraphs = (_body$paragraphs = body === null || body === void 0 ? void 0 : body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : [];
16928
- const dataStream = (_body$dataStream = body === null || body === void 0 ? void 0 : body.dataStream) !== null && _body$dataStream !== void 0 ? _body$dataStream : "";
16929
- const currentParagraphs = (_BuildTextUtils$range = BuildTextUtils.range.getParagraphsInRanges(docRanges, paragraphs, dataStream)) !== null && _BuildTextUtils$range !== void 0 ? _BuildTextUtils$range : [];
16823
+ const paragraphs = (body === null || body === void 0 ? void 0 : body.paragraphs) ?? [];
16824
+ const dataStream = (body === null || body === void 0 ? void 0 : body.dataStream) ?? "";
16825
+ const currentParagraphs = BuildTextUtils.range.getParagraphsInRanges(docRanges, paragraphs, dataStream) ?? [];
16930
16826
  return body == null ? currentParagraphs : resolveParagraphsForSettingPanel(currentParagraphs, body, docDataModel.getDocumentStyle());
16931
16827
  };
16932
16828
  const useFirstParagraphHorizontalAlign = (paragraph, defaultValue) => {
16933
16829
  const commandService = useDependency(ICommandService);
16934
16830
  const [horizontalAlign, setHorizontalAlignSetInternal] = useState(() => {
16935
- var _firstParagraph$parag, _firstParagraph$parag2;
16831
+ var _firstParagraph$parag;
16936
16832
  const firstParagraph = paragraph[0];
16937
16833
  if (!firstParagraph) return defaultValue;
16938
- return String((_firstParagraph$parag = (_firstParagraph$parag2 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag2 === void 0 ? void 0 : _firstParagraph$parag2.horizontalAlign) !== null && _firstParagraph$parag !== void 0 ? _firstParagraph$parag : defaultValue);
16834
+ return String(((_firstParagraph$parag = firstParagraph.paragraphStyle) === null || _firstParagraph$parag === void 0 ? void 0 : _firstParagraph$parag.horizontalAlign) ?? defaultValue);
16939
16835
  });
16940
16836
  const sethorizontalAlign = (v) => {
16941
16837
  setHorizontalAlignSetInternal(v);
@@ -16946,10 +16842,10 @@ const useFirstParagraphHorizontalAlign = (paragraph, defaultValue) => {
16946
16842
  const useFirstParagraphIndentStart = (paragraph) => {
16947
16843
  const commandService = useDependency(ICommandService);
16948
16844
  const [indentStart, setIndentStartInternal] = useState(() => {
16949
- var _firstParagraph$parag3;
16845
+ var _firstParagraph$parag2;
16950
16846
  const firstParagraph = paragraph[0];
16951
16847
  if (!firstParagraph) return 0;
16952
- return getNumberUnitValue((_firstParagraph$parag3 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag3 === void 0 ? void 0 : _firstParagraph$parag3.indentStart, 0);
16848
+ return getNumberUnitValue((_firstParagraph$parag2 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag2 === void 0 ? void 0 : _firstParagraph$parag2.indentStart, 0);
16953
16849
  });
16954
16850
  const setIndentStart = (v) => {
16955
16851
  setIndentStartInternal(v);
@@ -16960,10 +16856,10 @@ const useFirstParagraphIndentStart = (paragraph) => {
16960
16856
  const useFirstParagraphIndentEnd = (paragraph) => {
16961
16857
  const commandService = useDependency(ICommandService);
16962
16858
  const [indentEnd, setIndentEndInternal] = useState(() => {
16963
- var _firstParagraph$parag4;
16859
+ var _firstParagraph$parag3;
16964
16860
  const firstParagraph = paragraph[0];
16965
16861
  if (!firstParagraph) return 0;
16966
- return getNumberUnitValue((_firstParagraph$parag4 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag4 === void 0 ? void 0 : _firstParagraph$parag4.indentEnd, 0);
16862
+ return getNumberUnitValue((_firstParagraph$parag3 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag3 === void 0 ? void 0 : _firstParagraph$parag3.indentEnd, 0);
16967
16863
  });
16968
16864
  const setIndentEnd = (v) => {
16969
16865
  setIndentEndInternal(v);
@@ -16974,10 +16870,10 @@ const useFirstParagraphIndentEnd = (paragraph) => {
16974
16870
  const useFirstParagraphIndentFirstLine = (paragraph) => {
16975
16871
  const commandService = useDependency(ICommandService);
16976
16872
  const [indentFirstLine, setIndentFirstLineInternal] = useState(() => {
16977
- var _firstParagraph$parag5;
16873
+ var _firstParagraph$parag4;
16978
16874
  const firstParagraph = paragraph[0];
16979
16875
  if (!firstParagraph) return 0;
16980
- return getNumberUnitValue((_firstParagraph$parag5 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag5 === void 0 ? void 0 : _firstParagraph$parag5.indentFirstLine, 0);
16876
+ return getNumberUnitValue((_firstParagraph$parag4 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag4 === void 0 ? void 0 : _firstParagraph$parag4.indentFirstLine, 0);
16981
16877
  });
16982
16878
  const setIndentFirstLine = (v) => {
16983
16879
  setIndentFirstLineInternal(v);
@@ -16988,10 +16884,10 @@ const useFirstParagraphIndentFirstLine = (paragraph) => {
16988
16884
  const useFirstParagraphIndentHanging = (paragraph) => {
16989
16885
  const commandService = useDependency(ICommandService);
16990
16886
  const [hanging, setHangingInternal] = useState(() => {
16991
- var _firstParagraph$parag6;
16887
+ var _firstParagraph$parag5;
16992
16888
  const firstParagraph = paragraph[0];
16993
16889
  if (!firstParagraph) return 0;
16994
- return getNumberUnitValue((_firstParagraph$parag6 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag6 === void 0 ? void 0 : _firstParagraph$parag6.hanging, 0);
16890
+ return getNumberUnitValue((_firstParagraph$parag5 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag5 === void 0 ? void 0 : _firstParagraph$parag5.hanging, 0);
16995
16891
  });
16996
16892
  const setHanging = (v) => {
16997
16893
  setHangingInternal(v);
@@ -17002,10 +16898,10 @@ const useFirstParagraphIndentHanging = (paragraph) => {
17002
16898
  const useFirstParagraphIndentSpaceAbove = (paragraph) => {
17003
16899
  const commandService = useDependency(ICommandService);
17004
16900
  const [spaceAbove, setSpaceAboveInternal] = useState(() => {
17005
- var _firstParagraph$parag7;
16901
+ var _firstParagraph$parag6;
17006
16902
  const firstParagraph = paragraph[0];
17007
16903
  if (!firstParagraph) return 0;
17008
- return getNumberUnitValue((_firstParagraph$parag7 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag7 === void 0 ? void 0 : _firstParagraph$parag7.spaceAbove, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE);
16904
+ return getNumberUnitValue((_firstParagraph$parag6 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag6 === void 0 ? void 0 : _firstParagraph$parag6.spaceAbove, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE);
17009
16905
  });
17010
16906
  const setSpaceAbove = (v) => {
17011
16907
  setSpaceAboveInternal(v);
@@ -17016,10 +16912,10 @@ const useFirstParagraphIndentSpaceAbove = (paragraph) => {
17016
16912
  const useFirstParagraphSpaceBelow = (paragraph) => {
17017
16913
  const commandService = useDependency(ICommandService);
17018
16914
  const [spaceBelow, setSpaceBelowInternal] = useState(() => {
17019
- var _firstParagraph$parag8;
16915
+ var _firstParagraph$parag7;
17020
16916
  const firstParagraph = paragraph[0];
17021
16917
  if (!firstParagraph) return 0;
17022
- return getNumberUnitValue((_firstParagraph$parag8 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag8 === void 0 ? void 0 : _firstParagraph$parag8.spaceBelow, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW);
16918
+ return getNumberUnitValue((_firstParagraph$parag7 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag7 === void 0 ? void 0 : _firstParagraph$parag7.spaceBelow, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW);
17023
16919
  });
17024
16920
  const setSpaceBelow = (v) => {
17025
16921
  setSpaceBelowInternal(v);
@@ -17039,17 +16935,17 @@ const useFirstParagraphLineSpacing = (paragraph) => {
17039
16935
  }, []);
17040
16936
  const stateChange$ = useMemo(() => new BehaviorSubject({}), []);
17041
16937
  const [spacingRule, setSpacingRuleInternal] = useState(() => {
17042
- var _firstParagraph$parag9, _firstParagraph$parag10;
16938
+ var _firstParagraph$parag8;
17043
16939
  const firstParagraph = paragraph[0];
17044
16940
  if (!firstParagraph) return SpacingRule.AUTO;
17045
- return (_firstParagraph$parag9 = (_firstParagraph$parag10 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag10 === void 0 ? void 0 : _firstParagraph$parag10.spacingRule) !== null && _firstParagraph$parag9 !== void 0 ? _firstParagraph$parag9 : SpacingRule.AUTO;
16941
+ return ((_firstParagraph$parag8 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag8 === void 0 ? void 0 : _firstParagraph$parag8.spacingRule) ?? SpacingRule.AUTO;
17046
16942
  });
17047
16943
  const [lineSpacing, setLineSpacingInternal] = useState(() => {
17048
- var _firstParagraph$parag11, _firstParagraph$parag12, _firstParagraph$parag13, _firstParagraph$parag14;
16944
+ var _firstParagraph$parag9, _firstParagraph$parag10;
17049
16945
  const firstParagraph = paragraph[0];
17050
16946
  if (!firstParagraph) return DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING;
17051
- const currentSpacingRule = (_firstParagraph$parag11 = (_firstParagraph$parag12 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag12 === void 0 ? void 0 : _firstParagraph$parag12.spacingRule) !== null && _firstParagraph$parag11 !== void 0 ? _firstParagraph$parag11 : SpacingRule.AUTO;
17052
- return convertStoredLineSpacingToDisplayValue((_firstParagraph$parag13 = (_firstParagraph$parag14 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag14 === void 0 ? void 0 : _firstParagraph$parag14.lineSpacing) !== null && _firstParagraph$parag13 !== void 0 ? _firstParagraph$parag13 : DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, currentSpacingRule);
16947
+ const currentSpacingRule = ((_firstParagraph$parag9 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag9 === void 0 ? void 0 : _firstParagraph$parag9.spacingRule) ?? SpacingRule.AUTO;
16948
+ return convertStoredLineSpacingToDisplayValue(((_firstParagraph$parag10 = firstParagraph.paragraphStyle) === null || _firstParagraph$parag10 === void 0 ? void 0 : _firstParagraph$parag10.lineSpacing) ?? DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, currentSpacingRule);
17053
16949
  });
17054
16950
  const setLineSpacing = async (v) => {
17055
16951
  setLineSpacingInternal(v);
@@ -17117,13 +17013,12 @@ const ALIGNMENT_OPTIONS = [
17117
17013
  }
17118
17014
  ];
17119
17015
  const ParagraphSettingSection = (props) => {
17120
- const { titleKey, children, first = false } = props;
17121
- const localeService = useDependency(LocaleService);
17016
+ const { title, children, first = false } = props;
17122
17017
  return /* @__PURE__ */ jsxs("section", {
17123
17018
  className: clsx(!first && "univer-mt-5"),
17124
17019
  children: [/* @__PURE__ */ jsx("div", {
17125
17020
  className: "univer-text-sm univer-font-medium univer-leading-5",
17126
- children: localeService.t(titleKey)
17021
+ children: title
17127
17022
  }), /* @__PURE__ */ jsx("div", {
17128
17023
  className: "univer-mt-3",
17129
17024
  children
@@ -17131,13 +17026,13 @@ const ParagraphSettingSection = (props) => {
17131
17026
  });
17132
17027
  };
17133
17028
  const ParagraphSettingRow = (props) => {
17134
- const { labelKey, unit, children } = props;
17029
+ const { label, unit, children } = props;
17135
17030
  return /* @__PURE__ */ jsxs("div", {
17136
17031
  className: "univer-grid univer-min-h-8 univer-items-center univer-gap-3",
17137
17032
  style: { gridTemplateColumns: "minmax(0, 1fr) minmax(160px, 180px)" },
17138
17033
  children: [/* @__PURE__ */ jsxs("div", {
17139
17034
  className: "univer-min-w-0 univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-text-gray-100",
17140
- children: [useDependency(LocaleService).t(labelKey), unit]
17035
+ children: [label, unit]
17141
17036
  }), /* @__PURE__ */ jsx("div", {
17142
17037
  className: "univer-w-full univer-min-w-0",
17143
17038
  children
@@ -17155,7 +17050,7 @@ const AutoFocusInputNumber = (props) => {
17155
17050
  max,
17156
17051
  value,
17157
17052
  onChange: (v) => {
17158
- onChange(v !== null && v !== void 0 ? v : 0).finally(() => {
17053
+ onChange(v ?? 0).finally(() => {
17159
17054
  setTimeout(() => {
17160
17055
  var _ref$current;
17161
17056
  (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
@@ -17185,7 +17080,7 @@ function ParagraphSetting() {
17185
17080
  className: "univer-box-border univer-w-full",
17186
17081
  children: [
17187
17082
  /* @__PURE__ */ jsx(ParagraphSettingSection, {
17188
- titleKey: "docs-ui.doc.paragraphSetting.alignment",
17083
+ title: localeService.t("docs-ui.doc.paragraphSetting.alignment"),
17189
17084
  first: true,
17190
17085
  children: /* @__PURE__ */ jsx("div", {
17191
17086
  className: clsx("univer-flex univer-grid-cols-4 univer-items-center univer-justify-around univer-gap-2 univer-rounded-lg univer-bg-white univer-p-1 dark:!univer-bg-gray-900", borderClassName),
@@ -17211,68 +17106,68 @@ function ParagraphSetting() {
17211
17106
  })
17212
17107
  }),
17213
17108
  /* @__PURE__ */ jsx(ParagraphSettingSection, {
17214
- titleKey: "docs-ui.doc.paragraphSetting.indentation",
17109
+ title: localeService.t("docs-ui.doc.paragraphSetting.indentation"),
17215
17110
  children: /* @__PURE__ */ jsxs("div", {
17216
17111
  className: "univer-grid univer-gap-3",
17217
17112
  children: [
17218
17113
  /* @__PURE__ */ jsx(ParagraphSettingRow, {
17219
- labelKey: "docs-ui.doc.paragraphSetting.left",
17114
+ label: localeService.t("docs-ui.doc.paragraphSetting.left"),
17220
17115
  unit: "(px)",
17221
17116
  children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
17222
17117
  value: indentStart,
17223
- onChange: (v) => setIndentStart(v !== null && v !== void 0 ? v : 0)
17118
+ onChange: (v) => setIndentStart(v ?? 0)
17224
17119
  })
17225
17120
  }),
17226
17121
  /* @__PURE__ */ jsx(ParagraphSettingRow, {
17227
- labelKey: "docs-ui.doc.paragraphSetting.right",
17122
+ label: localeService.t("docs-ui.doc.paragraphSetting.right"),
17228
17123
  unit: "(px)",
17229
17124
  children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
17230
17125
  value: indentEnd,
17231
- onChange: (v) => setIndentEnd(v !== null && v !== void 0 ? v : 0)
17126
+ onChange: (v) => setIndentEnd(v ?? 0)
17232
17127
  })
17233
17128
  }),
17234
17129
  /* @__PURE__ */ jsx(ParagraphSettingRow, {
17235
- labelKey: "docs-ui.doc.paragraphSetting.firstLine",
17130
+ label: localeService.t("docs-ui.doc.paragraphSetting.firstLine"),
17236
17131
  unit: "(px)",
17237
17132
  children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
17238
17133
  value: indentFirstLine,
17239
- onChange: (v) => setIndentFirstLine(v !== null && v !== void 0 ? v : 0)
17134
+ onChange: (v) => setIndentFirstLine(v ?? 0)
17240
17135
  })
17241
17136
  }),
17242
17137
  /* @__PURE__ */ jsx(ParagraphSettingRow, {
17243
- labelKey: "docs-ui.doc.paragraphSetting.hanging",
17138
+ label: localeService.t("docs-ui.doc.paragraphSetting.hanging"),
17244
17139
  unit: "(px)",
17245
17140
  children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
17246
17141
  value: hanging,
17247
- onChange: (v) => setHanging(v !== null && v !== void 0 ? v : 0)
17142
+ onChange: (v) => setHanging(v ?? 0)
17248
17143
  })
17249
17144
  })
17250
17145
  ]
17251
17146
  })
17252
17147
  }),
17253
17148
  /* @__PURE__ */ jsx(ParagraphSettingSection, {
17254
- titleKey: "docs-ui.doc.paragraphSetting.spacing",
17149
+ title: localeService.t("docs-ui.doc.paragraphSetting.spacing"),
17255
17150
  children: /* @__PURE__ */ jsxs("div", {
17256
17151
  className: "univer-grid univer-gap-3",
17257
17152
  children: [
17258
17153
  /* @__PURE__ */ jsx(ParagraphSettingRow, {
17259
- labelKey: "docs-ui.doc.paragraphSetting.before",
17154
+ label: localeService.t("docs-ui.doc.paragraphSetting.before"),
17260
17155
  unit: "(px)",
17261
17156
  children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
17262
17157
  value: spaceAbove,
17263
- onChange: (v) => setSpaceAbove(v !== null && v !== void 0 ? v : 0)
17158
+ onChange: (v) => setSpaceAbove(v ?? 0)
17264
17159
  })
17265
17160
  }),
17266
17161
  /* @__PURE__ */ jsx(ParagraphSettingRow, {
17267
- labelKey: "docs-ui.doc.paragraphSetting.after",
17162
+ label: localeService.t("docs-ui.doc.paragraphSetting.after"),
17268
17163
  unit: "(px)",
17269
17164
  children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
17270
17165
  value: spaceBelow,
17271
- onChange: (v) => setSpaceBelow(v !== null && v !== void 0 ? v : 0)
17166
+ onChange: (v) => setSpaceBelow(v ?? 0)
17272
17167
  })
17273
17168
  }),
17274
17169
  /* @__PURE__ */ jsx(ParagraphSettingRow, {
17275
- labelKey: "docs-ui.doc.paragraphSetting.lineSpace",
17170
+ label: localeService.t("docs-ui.doc.paragraphSetting.lineSpace"),
17276
17171
  children: /* @__PURE__ */ jsxs("div", {
17277
17172
  className: "univer-flex univer-w-full univer-flex-col univer-gap-2",
17278
17173
  children: [/* @__PURE__ */ jsx(Select, {
@@ -17283,7 +17178,7 @@ function ParagraphSetting() {
17283
17178
  }), /* @__PURE__ */ jsx(AutoFocusInputNumber, {
17284
17179
  ...lineSpaceConfig,
17285
17180
  value: lineSpacing,
17286
- onChange: (v) => setLineSpacing(v !== null && v !== void 0 ? v : 0)
17181
+ onChange: (v) => setLineSpacing(v ?? 0)
17287
17182
  })]
17288
17183
  })
17289
17184
  })
@@ -17420,8 +17315,8 @@ DocFloatMenuService = __decorate([
17420
17315
  __decorateParam(5, IContextService)
17421
17316
  ], DocFloatMenuService);
17422
17317
  function isRangeInCodeBlock(documentDataModel, range) {
17423
- var _documentDataModel$ge3, _documentDataModel$ge4;
17424
- return ((_documentDataModel$ge3 = (_documentDataModel$ge4 = documentDataModel.getBody()) === null || _documentDataModel$ge4 === void 0 ? void 0 : _documentDataModel$ge4.blockRanges) !== null && _documentDataModel$ge3 !== void 0 ? _documentDataModel$ge3 : []).some((blockRange) => blockRange.blockType === DocumentBlockRangeType.CODE && Math.max(range.startOffset, blockRange.startIndex) <= Math.min(range.endOffset, blockRange.endIndex));
17318
+ var _documentDataModel$ge3;
17319
+ return (((_documentDataModel$ge3 = documentDataModel.getBody()) === null || _documentDataModel$ge3 === void 0 ? void 0 : _documentDataModel$ge3.blockRanges) ?? []).some((blockRange) => blockRange.blockType === DocumentBlockRangeType.CODE && Math.max(range.startOffset, blockRange.startIndex) <= Math.min(range.endOffset, blockRange.endIndex));
17425
17320
  }
17426
17321
 
17427
17322
  //#endregion
@@ -17458,8 +17353,8 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17458
17353
  return (_this$_paragraphMenu = this._paragraphMenu) === null || _this$_paragraphMenu === void 0 ? void 0 : _this$_paragraphMenu.paragraph;
17459
17354
  }
17460
17355
  get activeTarget() {
17461
- var _this$_paragraphMenu$, _this$_paragraphMenu2;
17462
- return (_this$_paragraphMenu$ = (_this$_paragraphMenu2 = this._paragraphMenu) === null || _this$_paragraphMenu2 === void 0 ? void 0 : _this$_paragraphMenu2.target) !== null && _this$_paragraphMenu$ !== void 0 ? _this$_paragraphMenu$ : null;
17356
+ var _this$_paragraphMenu2;
17357
+ return ((_this$_paragraphMenu2 = this._paragraphMenu) === null || _this$_paragraphMenu2 === void 0 ? void 0 : _this$_paragraphMenu2.target) ?? null;
17463
17358
  }
17464
17359
  setBlockMenuDragging(isDragging) {
17465
17360
  this._isBlockMenuDragging = isDragging;
@@ -17525,7 +17420,6 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17525
17420
  if (this._paragraphMenu) this._paragraphMenu.active = active;
17526
17421
  }
17527
17422
  _init() {
17528
- var _this$_docEventManage;
17529
17423
  const handleHoverTarget = (paragraph, tableBound) => {
17530
17424
  if (this._isBlockMenuDragging) return;
17531
17425
  if (this._docSelectionRenderService.isOnPointerEvent) {
@@ -17564,12 +17458,12 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17564
17458
  this.disposeWithMe(combineLatest([
17565
17459
  this._docEventManagerService.hoverParagraphRealTime$,
17566
17460
  this._docEventManagerService.hoverParagraphLeft$,
17567
- (_this$_docEventManage = this._docEventManagerService.hoverTableRealTime$) !== null && _this$_docEventManage !== void 0 ? _this$_docEventManage : new BehaviorSubject(null)
17461
+ this._docEventManagerService.hoverTableRealTime$ ?? new BehaviorSubject(null)
17568
17462
  ]).pipe(throttleTime(16, void 0, {
17569
17463
  leading: true,
17570
17464
  trailing: true
17571
17465
  })).subscribe(([p, left, table]) => {
17572
- handleHoverTarget(p !== null && p !== void 0 ? p : left, table);
17466
+ handleHoverTarget(p ?? left, table);
17573
17467
  }));
17574
17468
  this.disposeWithMe(this._docSelectionRenderService.onSelectionStart$.subscribe(() => {
17575
17469
  this.hideParagraphMenu(true);
@@ -17632,14 +17526,12 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17632
17526
  return this._getCollapsedTextRange(config) != null;
17633
17527
  }
17634
17528
  _shouldOpenSlashMenuFromInput(config) {
17635
- var _ref, _config$content;
17636
17529
  const event = config.event;
17637
- if (((_ref = (_config$content = config.content) !== null && _config$content !== void 0 ? _config$content : event.data) !== null && _ref !== void 0 ? _ref : "") !== "/") return false;
17530
+ if ((config.content ?? event.data ?? "") !== "/") return false;
17638
17531
  return this._getCollapsedTextRange(config) != null;
17639
17532
  }
17640
17533
  _getCollapsedTextRange(config) {
17641
- var _config$activeRange;
17642
- const activeRange = (_config$activeRange = config.activeRange) !== null && _config$activeRange !== void 0 ? _config$activeRange : this._docSelectionManagerService.getActiveTextRange();
17534
+ const activeRange = config.activeRange ?? this._docSelectionManagerService.getActiveTextRange();
17643
17535
  if (!activeRange) return null;
17644
17536
  if (activeRange.collapsed || activeRange.startOffset === activeRange.endOffset) return {
17645
17537
  ...activeRange,
@@ -17648,31 +17540,31 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17648
17540
  return null;
17649
17541
  }
17650
17542
  _getSlashMenuParagraph(config) {
17651
- var _this$_paragraphMenu$2, _this$_paragraphMenu7, _find;
17543
+ var _this$_paragraphMenu7;
17652
17544
  const activeRange = this._getCollapsedTextRange(config);
17653
17545
  const offset = activeRange === null || activeRange === void 0 ? void 0 : activeRange.startOffset;
17654
- const activeParagraph = (_this$_paragraphMenu$2 = (_this$_paragraphMenu7 = this._paragraphMenu) === null || _this$_paragraphMenu7 === void 0 ? void 0 : _this$_paragraphMenu7.paragraph) !== null && _this$_paragraphMenu$2 !== void 0 ? _this$_paragraphMenu$2 : null;
17546
+ const activeParagraph = ((_this$_paragraphMenu7 = this._paragraphMenu) === null || _this$_paragraphMenu7 === void 0 ? void 0 : _this$_paragraphMenu7.paragraph) ?? null;
17655
17547
  if (activeParagraph && offset != null && offset >= activeParagraph.paragraphStart && offset <= activeParagraph.paragraphEnd) return activeParagraph;
17656
17548
  if (activeParagraph && offset == null) return activeParagraph;
17657
17549
  if (offset == null) return null;
17658
- return (_find = [...this._docEventManagerService.paragraphBounds.values()].find((paragraph) => offset >= paragraph.paragraphStart && offset <= paragraph.paragraphEnd)) !== null && _find !== void 0 ? _find : null;
17550
+ return [...this._docEventManagerService.paragraphBounds.values()].find((paragraph) => offset >= paragraph.paragraphStart && offset <= paragraph.paragraphEnd) ?? null;
17659
17551
  }
17660
17552
  _getSlashMenuAnchorRect(config, paragraph) {
17661
17553
  const activeRange = this._getCollapsedTextRange(config);
17662
17554
  if (!activeRange) return paragraph.firstLine;
17663
17555
  try {
17664
- var _calcDocRangePosition, _calcDocRangePosition2;
17665
- return (_calcDocRangePosition = (_calcDocRangePosition2 = calcDocRangePositions({
17556
+ var _calcDocRangePosition;
17557
+ return ((_calcDocRangePosition = calcDocRangePositions({
17666
17558
  ...activeRange,
17667
17559
  collapsed: true,
17668
17560
  endOffset: activeRange.startOffset
17669
- }, this._context)) === null || _calcDocRangePosition2 === void 0 ? void 0 : _calcDocRangePosition2[0]) !== null && _calcDocRangePosition !== void 0 ? _calcDocRangePosition : paragraph.firstLine;
17561
+ }, this._context)) === null || _calcDocRangePosition === void 0 ? void 0 : _calcDocRangePosition[0]) ?? paragraph.firstLine;
17670
17562
  } catch {
17671
17563
  return paragraph.firstLine;
17672
17564
  }
17673
17565
  }
17674
17566
  showParagraphMenu(paragraph) {
17675
- var _this$_paragraphMenu8, _target$paragraph;
17567
+ var _this$_paragraphMenu8;
17676
17568
  if (this._hasExpandedSelection()) {
17677
17569
  this.hideParagraphMenu(true);
17678
17570
  return;
@@ -17684,12 +17576,11 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17684
17576
  }
17685
17577
  if (((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.target.key) === target.key) return;
17686
17578
  this.hideParagraphMenu(true);
17687
- const targetParagraph = (_target$paragraph = target.paragraph) !== null && _target$paragraph !== void 0 ? _target$paragraph : paragraph;
17579
+ const targetParagraph = target.paragraph ?? paragraph;
17688
17580
  const blockRange = target.blockRange;
17689
17581
  const getFirstLine = () => {
17690
- var _this$_docEventManage2, _latestParagraphBound;
17691
- const latestParagraphBound = (_this$_docEventManage2 = this._docEventManagerService.findParagraphBoundByIndex(targetParagraph.startIndex)) !== null && _this$_docEventManage2 !== void 0 ? _this$_docEventManage2 : targetParagraph;
17692
- const baseAnchor = blockRange ? getBlockRangeAnchorRect(this._docEventManagerService, blockRange, paragraph) : (_latestParagraphBound = latestParagraphBound.firstLine) !== null && _latestParagraphBound !== void 0 ? _latestParagraphBound : paragraph.firstLine;
17582
+ const latestParagraphBound = this._docEventManagerService.findParagraphBoundByIndex(targetParagraph.startIndex) ?? targetParagraph;
17583
+ const baseAnchor = blockRange ? getBlockRangeAnchorRect(this._docEventManagerService, blockRange, paragraph) : latestParagraphBound.firstLine ?? paragraph.firstLine;
17693
17584
  if (!target.cellRange) return baseAnchor;
17694
17585
  return getTableCellParagraphAnchorRect(this._docEventManagerService, latestParagraphBound, baseAnchor);
17695
17586
  };
@@ -17755,10 +17646,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17755
17646
  firstLine: anchorRect
17756
17647
  };
17757
17648
  this.hideParagraphMenu(true);
17758
- const getFirstLine = () => {
17759
- var _this$_docEventManage3;
17760
- return getTableAnchorRect((_this$_docEventManage3 = this._docEventManagerService.tableBounds.get(table.tableId)) !== null && _this$_docEventManage3 !== void 0 ? _this$_docEventManage3 : tableBound);
17761
- };
17649
+ const getFirstLine = () => getTableAnchorRect(this._docEventManagerService.tableBounds.get(table.tableId) ?? tableBound);
17762
17650
  const disposable = this._docPopupManagerService.attachPopupToRect(getFirstLine, {
17763
17651
  componentKey: DOC_TABLE_BLOCK_MENU_COMPONENT_KEY,
17764
17652
  direction: "top-right",
@@ -17827,9 +17715,9 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17827
17715
  }
17828
17716
  }
17829
17717
  _buildParagraphMenuTarget(paragraph) {
17830
- var _body$dataStream, _body$paragraphs, _paragraphModel$bulle, _paragraphModel$parag, _body$customBlocks;
17718
+ var _body$paragraphs, _paragraphModel$bulle, _paragraphModel$parag, _body$customBlocks;
17831
17719
  const body = this._context.unit.getBody();
17832
- const dataStream = (_body$dataStream = body === null || body === void 0 ? void 0 : body.dataStream) !== null && _body$dataStream !== void 0 ? _body$dataStream : "";
17720
+ const dataStream = (body === null || body === void 0 ? void 0 : body.dataStream) ?? "";
17833
17721
  const cellRange = getContainingTableCellRange(dataStream, paragraph.paragraphStart);
17834
17722
  const inTable = cellRange != null || isParagraphInTable(this._context.unit, paragraph.paragraphStart);
17835
17723
  const blockRange = getParagraphBlockRange(this._context.unit, paragraph);
@@ -17847,7 +17735,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17847
17735
  paragraph: targetParagraph,
17848
17736
  blockRange,
17849
17737
  icon: BLOCK_RANGE_ICON_MAP[blockRange.blockType],
17850
- cellRange: cellRange !== null && cellRange !== void 0 ? cellRange : void 0,
17738
+ cellRange: cellRange ?? void 0,
17851
17739
  menuRange: {
17852
17740
  startOffset: blockRange.startIndex,
17853
17741
  endOffset: blockRange.endIndex + 1,
@@ -17873,7 +17761,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17873
17761
  paragraph,
17874
17762
  customBlock,
17875
17763
  icon: "TextTypeIcon",
17876
- cellRange: cellRange !== null && cellRange !== void 0 ? cellRange : void 0,
17764
+ cellRange: cellRange ?? void 0,
17877
17765
  menuRange: {
17878
17766
  startOffset: customBlock.startIndex,
17879
17767
  endOffset: customBlock.startIndex,
@@ -17889,7 +17777,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17889
17777
  key: `${DocumentBlockType.PARAGRAPH}:${paragraph.startIndex}`,
17890
17778
  paragraph,
17891
17779
  icon: isHorizontalRuleParagraph ? "ReduceIcon" : listIcon,
17892
- cellRange: cellRange !== null && cellRange !== void 0 ? cellRange : void 0,
17780
+ cellRange: cellRange ?? void 0,
17893
17781
  menuRange: {
17894
17782
  startOffset: paragraph.paragraphStart,
17895
17783
  endOffset: paragraph.paragraphStart,
@@ -17901,11 +17789,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17901
17789
  };
17902
17790
  }
17903
17791
  _getBodyBlockTargets() {
17904
- var _body$tables2, _body$blockRanges;
17905
17792
  const body = this._context.unit.getBody();
17906
17793
  if (!body) return [];
17907
- const tableRanges = (_body$tables2 = body.tables) !== null && _body$tables2 !== void 0 ? _body$tables2 : [];
17908
- const blockRanges = (_body$blockRanges = body.blockRanges) !== null && _body$blockRanges !== void 0 ? _body$blockRanges : [];
17794
+ const tableRanges = body.tables ?? [];
17795
+ const blockRanges = body.blockRanges ?? [];
17909
17796
  const paragraphBounds = [...this._docEventManagerService.paragraphBounds.values()];
17910
17797
  const targets = [];
17911
17798
  for (const table of tableRanges) {
@@ -17965,10 +17852,9 @@ let DocParagraphMenuService = class DocParagraphMenuService extends Disposable {
17965
17852
  return targets;
17966
17853
  }
17967
17854
  _getCellBlockTargets(cellRange) {
17968
- var _body$blockRanges2;
17969
17855
  const body = this._context.unit.getBody();
17970
17856
  if (!body) return [];
17971
- const blockRanges = (_body$blockRanges2 = body.blockRanges) !== null && _body$blockRanges2 !== void 0 ? _body$blockRanges2 : [];
17857
+ const blockRanges = body.blockRanges ?? [];
17972
17858
  const paragraphBounds = [...this._docEventManagerService.paragraphBounds.values()].filter((paragraph) => paragraph.paragraphStart > cellRange.startOffset && paragraph.paragraphStart < cellRange.endOffset);
17973
17859
  const targets = [];
17974
17860
  for (const blockRange of blockRanges) {
@@ -18016,8 +17902,8 @@ DocParagraphMenuService = __decorate([
18016
17902
  __decorateParam(6, Inject(DocSelectionRenderService))
18017
17903
  ], DocParagraphMenuService);
18018
17904
  function isParagraphInTable(documentDataModel, paragraphStart) {
18019
- var _documentDataModel$ge, _documentDataModel$ge2;
18020
- return ((_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.tables) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : []).some((table) => paragraphStart > table.startIndex && paragraphStart < table.endIndex);
17905
+ var _documentDataModel$ge;
17906
+ return (((_documentDataModel$ge = documentDataModel.getBody()) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.tables) ?? []).some((table) => paragraphStart > table.startIndex && paragraphStart < table.endIndex);
18021
17907
  }
18022
17908
  function getParagraphMoveRange(documentDataModel, paragraph, cellRange) {
18023
17909
  const body = documentDataModel.getBody();
@@ -18077,13 +17963,13 @@ function unionRects(rects) {
18077
17963
  }));
18078
17964
  }
18079
17965
  function getParagraphBlockRange(documentDataModel, paragraph) {
18080
- var _documentDataModel$ge3, _documentDataModel$ge4;
18081
- return ((_documentDataModel$ge3 = (_documentDataModel$ge4 = documentDataModel.getBody()) === null || _documentDataModel$ge4 === void 0 ? void 0 : _documentDataModel$ge4.blockRanges) !== null && _documentDataModel$ge3 !== void 0 ? _documentDataModel$ge3 : []).find((range) => Math.max(paragraph.paragraphStart, range.startIndex) <= Math.min(paragraph.paragraphEnd, range.endIndex));
17966
+ var _documentDataModel$ge2;
17967
+ return (((_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.blockRanges) ?? []).find((range) => Math.max(paragraph.paragraphStart, range.startIndex) <= Math.min(paragraph.paragraphEnd, range.endIndex));
18082
17968
  }
18083
17969
  function getBlockRangeAnchorRect(docEventManagerService, blockRange, fallbackParagraph) {
18084
- var _bounds$0$firstLine, _bounds$;
17970
+ var _bounds$;
18085
17971
  const bounds = docEventManagerService.findParagraphBoundsInRange(blockRange.startIndex, blockRange.endIndex).sort((left, right) => left.firstLine.top - right.firstLine.top || left.firstLine.left - right.firstLine.left);
18086
- const anchor = (_bounds$0$firstLine = (_bounds$ = bounds[0]) === null || _bounds$ === void 0 ? void 0 : _bounds$.firstLine) !== null && _bounds$0$firstLine !== void 0 ? _bounds$0$firstLine : fallbackParagraph.firstLine;
17972
+ const anchor = ((_bounds$ = bounds[0]) === null || _bounds$ === void 0 ? void 0 : _bounds$.firstLine) ?? fallbackParagraph.firstLine;
18087
17973
  const left = Math.min(...(bounds.length ? bounds : [fallbackParagraph]).map((bound) => bound.firstLine.left));
18088
17974
  const top = anchor.top;
18089
17975
  return {
@@ -18108,6 +17994,9 @@ const PARAGRAPH_MENU_HOVER_OPEN_DELAY = 800;
18108
17994
  const PARAGRAPH_MENU_HOVER_HIDE_DELAY = 240;
18109
17995
  const PARAGRAPH_MENU_HOVER_BRIDGE_EDGE_OVERLAP = 12;
18110
17996
  const PARAGRAPH_MENU_HOVER_BRIDGE_VERTICAL_PADDING = 8;
17997
+ function getParagraphMenuIconSizeClass(iconKey) {
17998
+ return iconKey === "TextTypeIcon" ? "univer-size-3" : "univer-size-4";
17999
+ }
18111
18000
  function shouldExecuteParagraphMenuMove(validatorService, context) {
18112
18001
  return validatorService.canMoveBlock(context);
18113
18002
  }
@@ -18201,8 +18090,7 @@ const NAMED_STYLE_HEADING_COMMAND_IDS = {
18201
18090
  [NamedStyleType.SUBTITLE]: SubtitleHeadingCommand.id
18202
18091
  };
18203
18092
  function getParagraphMenuActiveHeadingCommandId(namedStyleType) {
18204
- var _NAMED_STYLE_HEADING_;
18205
- return (_NAMED_STYLE_HEADING_ = NAMED_STYLE_HEADING_COMMAND_IDS[namedStyleType !== null && namedStyleType !== void 0 ? namedStyleType : NamedStyleType.NORMAL_TEXT]) !== null && _NAMED_STYLE_HEADING_ !== void 0 ? _NAMED_STYLE_HEADING_ : NormalTextHeadingCommand.id;
18093
+ return NAMED_STYLE_HEADING_COMMAND_IDS[namedStyleType ?? NamedStyleType.NORMAL_TEXT] ?? NormalTextHeadingCommand.id;
18206
18094
  }
18207
18095
  function getParagraphMenuHiddenHeadingCommandIds(namedStyleType) {
18208
18096
  if (namedStyleType === NamedStyleType.TITLE) return [
@@ -18271,8 +18159,7 @@ function shouldRestoreParagraphMenuSelectionAfterCommand(commandId) {
18271
18159
  return !!commandId && PARAGRAPH_MENU_RESTORE_SELECTION_COMMAND_IDS.has(commandId);
18272
18160
  }
18273
18161
  function getParagraphMenuCommand(params, targetRange) {
18274
- var _ref, _params$commandId;
18275
- const commandId = (_ref = (_params$commandId = params.commandId) !== null && _params$commandId !== void 0 ? _params$commandId : params.id) !== null && _ref !== void 0 ? _ref : typeof params.label === "string" ? params.label : void 0;
18162
+ const commandId = params.commandId ?? params.id ?? (typeof params.label === "string" ? params.label : void 0);
18276
18163
  if (commandId && targetRange && commandId in HEADING_COMMAND_VALUES) return {
18277
18164
  commandId: SetParagraphNamedStyleCommand.id,
18278
18165
  params: {
@@ -18296,19 +18183,18 @@ function getParagraphMenuCommand(params, targetRange) {
18296
18183
  };
18297
18184
  }
18298
18185
  function getParagraphMenuResolvedCommand(option, targetRange) {
18299
- var _ref2, _option$commandId, _option$id;
18300
- const commandId = (_ref2 = (_option$commandId = option.commandId) !== null && _option$commandId !== void 0 ? _option$commandId : option.id) !== null && _ref2 !== void 0 ? _ref2 : typeof option.label === "string" ? option.label : void 0;
18186
+ const commandId = option.commandId ?? option.id ?? (typeof option.label === "string" ? option.label : void 0);
18301
18187
  if (!commandId) return {};
18302
18188
  return getParagraphMenuCommand({
18303
18189
  ...option,
18304
18190
  commandId,
18305
- id: (_option$id = option.id) !== null && _option$id !== void 0 ? _option$id : commandId
18191
+ id: option.id ?? commandId
18306
18192
  }, targetRange);
18307
18193
  }
18308
18194
  function getParagraphMenuCommandParams(commandId, commandParams, target, unitId) {
18309
18195
  if (commandId !== DeleteCurrentParagraphCommand.id || (target === null || target === void 0 ? void 0 : target.kind) !== "blockRange" || !target.blockRange) return commandParams;
18310
18196
  return {
18311
- ...commandParams !== null && commandParams !== void 0 ? commandParams : {},
18197
+ ...commandParams ?? {},
18312
18198
  unitId,
18313
18199
  blockRange: target.blockRange
18314
18200
  };
@@ -18426,10 +18312,10 @@ function stripBlockParagraphStyle(style, blockType) {
18426
18312
  return nextStyle;
18427
18313
  }
18428
18314
  function unwrapBlockRangeBody(documentBody, blockRange) {
18429
- var _body$paragraphs, _body$blockRanges;
18315
+ var _body$blockRanges;
18430
18316
  const body = Tools.deepClone(documentBody);
18431
18317
  const endTokenOffset = getEndTokenOffset(body, blockRange);
18432
- ((_body$paragraphs = body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).filter((paragraph) => paragraph.startIndex > blockRange.startIndex && paragraph.startIndex < endTokenOffset).forEach((paragraph) => {
18318
+ (body.paragraphs ?? []).filter((paragraph) => paragraph.startIndex > blockRange.startIndex && paragraph.startIndex < endTokenOffset).forEach((paragraph) => {
18433
18319
  paragraph.paragraphStyle = stripBlockParagraphStyle(paragraph.paragraphStyle, blockRange.blockType);
18434
18320
  });
18435
18321
  deleteBodyText(body, endTokenOffset, endTokenOffset + 1);
@@ -18533,8 +18419,8 @@ function getParagraphFormattingRange(target, paragraph) {
18533
18419
  }
18534
18420
  function getParagraphMenuCommandTargetRange(commandId, targetRange, formattingRange) {
18535
18421
  if (commandId === DocPasteCommand.id) return targetRange;
18536
- if (commandId && PARAGRAPH_MENU_SELECTION_COMMAND_IDS.has(commandId)) return formattingRange !== null && formattingRange !== void 0 ? formattingRange : targetRange;
18537
- return targetRange !== null && targetRange !== void 0 ? targetRange : formattingRange;
18422
+ if (commandId && PARAGRAPH_MENU_SELECTION_COMMAND_IDS.has(commandId)) return formattingRange ?? targetRange;
18423
+ return targetRange ?? formattingRange;
18538
18424
  }
18539
18425
  function finishParagraphMenuCommand(docParagraphMenuService, layoutService, hideMenu) {
18540
18426
  docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.hideParagraphMenu(true);
@@ -18560,11 +18446,11 @@ function getBlockRangeClipboardTargetRange(commandId, target, paragraph) {
18560
18446
  collapsed: true,
18561
18447
  segmentId: paragraph === null || paragraph === void 0 ? void 0 : paragraph.segmentId
18562
18448
  };
18563
- if (commandId === DocCopyCurrentParagraphCommand.id || commandId === DocCutCurrentParagraphCommand.id) return getBlockSelectionRange(target, paragraph !== null && paragraph !== void 0 ? paragraph : void 0);
18449
+ if (commandId === DocCopyCurrentParagraphCommand.id || commandId === DocCutCurrentParagraphCommand.id) return getBlockSelectionRange(target, paragraph ?? void 0);
18564
18450
  return null;
18565
18451
  }
18566
18452
  function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18567
- var _ref3, _ref4, _currentActiveTarget$, _doc$getBody$dataStre, _doc$getBody, _currentActiveTarget$2, _paragraphObj$paragra, _currentActiveTarget$3;
18453
+ var _doc$getBody, _paragraphObj$paragra;
18568
18454
  const [visible, setVisible] = useState(false);
18569
18455
  const [openMode, setOpenMode] = useState("pointer");
18570
18456
  const [anchorRect, setAnchorRect] = useState(null);
@@ -18599,18 +18485,18 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18599
18485
  const slashMenuRequest = useObservable(docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.slashMenuRequest$);
18600
18486
  const paragraph = useObservable(docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.hoverParagraph$);
18601
18487
  const paragraphLeft = useObservable(docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.hoverParagraphLeft$);
18602
- const rawActiveTarget = activeTarget !== null && activeTarget !== void 0 ? activeTarget : docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget;
18488
+ const rawActiveTarget = activeTarget ?? (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget);
18603
18489
  const currentActiveTarget = tableBlockOnly ? (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" ? rawActiveTarget : null : (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" ? null : rawActiveTarget;
18604
- const activeParagraphBound = (_ref3 = (_ref4 = (_currentActiveTarget$ = currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.paragraph) !== null && _currentActiveTarget$ !== void 0 ? _currentActiveTarget$ : docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeParagraph) !== null && _ref4 !== void 0 ? _ref4 : paragraph) !== null && _ref3 !== void 0 ? _ref3 : paragraphLeft;
18490
+ const activeParagraphBound = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.paragraph) ?? (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeParagraph) ?? paragraph ?? paragraphLeft;
18605
18491
  const startIndex = activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.startIndex;
18606
- const dataStream = (_doc$getBody$dataStre = doc === null || doc === void 0 || (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) !== null && _doc$getBody$dataStre !== void 0 ? _doc$getBody$dataStre : "";
18492
+ const dataStream = (doc === null || doc === void 0 || (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) ?? "";
18607
18493
  const paragraphObj = useMemo(() => {
18608
18494
  var _doc$getBody2;
18609
18495
  return doc === null || doc === void 0 || (_doc$getBody2 = doc.getBody()) === null || _doc$getBody2 === void 0 || (_doc$getBody2 = _doc$getBody2.paragraphs) === null || _doc$getBody2 === void 0 ? void 0 : _doc$getBody2.find((p) => p.startIndex === startIndex);
18610
18496
  }, [doc, startIndex]);
18611
- const isEmptyParagraph = (_currentActiveTarget$2 = currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.emptyMode) !== null && _currentActiveTarget$2 !== void 0 ? _currentActiveTarget$2 : isEmptyParagraphMenuTarget(dataStream, activeParagraphBound);
18497
+ const isEmptyParagraph = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.emptyMode) ?? isEmptyParagraphMenuTarget(dataStream, activeParagraphBound);
18612
18498
  const namedStyleType = paragraphObj === null || paragraphObj === void 0 || (_paragraphObj$paragra = paragraphObj.paragraphStyle) === null || _paragraphObj$paragra === void 0 ? void 0 : _paragraphObj$paragra.namedStyleType;
18613
- const targetIconKey = (_currentActiveTarget$3 = currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) !== null && _currentActiveTarget$3 !== void 0 ? _currentActiveTarget$3 : getParagraphMenuTriggerIconKey(namedStyleType);
18499
+ const targetIconKey = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) ?? getParagraphMenuTriggerIconKey(namedStyleType);
18614
18500
  const TargetIcon = iconManager.get(targetIconKey);
18615
18501
  const paragraphMenuType = useMemo(() => getParagraphMenuType(currentActiveTarget, isEmptyParagraph), [currentActiveTarget, isEmptyParagraph]);
18616
18502
  const paragraphMenuActiveItemIds = useMemo(() => getParagraphMenuActiveItemIds(currentActiveTarget, namedStyleType), [currentActiveTarget, namedStyleType]);
@@ -18626,11 +18512,11 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18626
18512
  bottom: 0
18627
18513
  }), []);
18628
18514
  const updateAnchorRect = () => {
18629
- var _anchorRef$current, _boundingRect$left, _boundingRect$right, _anchorRef$current$ow, _anchorRef$current2, _boundingRect$top, _boundingRect$bottom;
18515
+ var _anchorRef$current, _anchorRef$current2;
18630
18516
  const boundingRect = (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.getBoundingClientRect();
18631
- const left = ((_boundingRect$left = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.left) !== null && _boundingRect$left !== void 0 ? _boundingRect$left : 0) - 4;
18632
- const right = (_boundingRect$right = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.right) !== null && _boundingRect$right !== void 0 ? _boundingRect$right : 0;
18633
- 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;
18517
+ const left = ((boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.left) ?? 0) - 4;
18518
+ const right = (boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.right) ?? 0;
18519
+ const viewportWidth = ((_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) ?? window.innerWidth;
18634
18520
  setMenuDirection(getParagraphMenuPopupDirection(left, 212, 8, {
18635
18521
  anchorRight: right,
18636
18522
  direction,
@@ -18639,8 +18525,8 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18639
18525
  const nextAnchorRect = {
18640
18526
  left,
18641
18527
  right,
18642
- top: (_boundingRect$top = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.top) !== null && _boundingRect$top !== void 0 ? _boundingRect$top : 0,
18643
- bottom: (_boundingRect$bottom = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.bottom) !== null && _boundingRect$bottom !== void 0 ? _boundingRect$bottom : 0
18528
+ top: (boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.top) ?? 0,
18529
+ bottom: (boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.bottom) ?? 0
18644
18530
  };
18645
18531
  setAnchorRect(nextAnchorRect);
18646
18532
  anchorRect$.next(nextAnchorRect);
@@ -18664,9 +18550,8 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18664
18550
  }, PARAGRAPH_MENU_HOVER_HIDE_DELAY);
18665
18551
  };
18666
18552
  const handleOpenMenu = (mode = "pointer") => {
18667
- var _docParagraphMenuServ;
18668
18553
  clearHideTimer();
18669
- const latestTarget = (_docParagraphMenuServ = docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) !== null && _docParagraphMenuServ !== void 0 ? _docParagraphMenuServ : activeTarget;
18554
+ const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
18670
18555
  setParagraphMenuInteractionActive(docParagraphMenuService, true);
18671
18556
  const targetRange = latestTarget ? {
18672
18557
  ...latestTarget.menuRange,
@@ -18679,11 +18564,11 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18679
18564
  };
18680
18565
  openMenuRef.current = handleOpenMenu;
18681
18566
  const handleOpenSlashMenu = (request) => {
18682
- var _request$target$parag, _request$target$parag2;
18567
+ var _request$target$parag;
18683
18568
  clearHideTimer();
18684
18569
  targetRangeRef.current = {
18685
18570
  ...request.target.menuRange,
18686
- segmentId: (_request$target$parag = (_request$target$parag2 = request.target.paragraph) === null || _request$target$parag2 === void 0 ? void 0 : _request$target$parag2.segmentId) !== null && _request$target$parag !== void 0 ? _request$target$parag : activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId
18571
+ segmentId: ((_request$target$parag = request.target.paragraph) === null || _request$target$parag === void 0 ? void 0 : _request$target$parag.segmentId) ?? (activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId)
18687
18572
  };
18688
18573
  setMenuDirection("vertical");
18689
18574
  setAnchorRect(request.anchorRect);
@@ -18703,8 +18588,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18703
18588
  docSelectionManagerService.replaceDocRanges([range], void 0, false);
18704
18589
  };
18705
18590
  const getCurrentTextRangesSnapshot = () => {
18706
- var _docSelectionManagerS;
18707
- return ((_docSelectionManagerS = docSelectionManagerService.getTextRanges()) !== null && _docSelectionManagerS !== void 0 ? _docSelectionManagerS : []).map((range) => ({ ...range }));
18591
+ return (docSelectionManagerService.getTextRanges() ?? []).map((range) => ({ ...range }));
18708
18592
  };
18709
18593
  const restoreTextRanges = (ranges) => {
18710
18594
  if (!ranges) return;
@@ -18716,13 +18600,12 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18716
18600
  return commandService.executeCommand(resolved.commandId, resolved.params);
18717
18601
  };
18718
18602
  const unwrapActiveBlockRange = async () => {
18719
- var _docParagraphMenuServ2, _activeParagraphBound;
18720
- const latestTarget = (_docParagraphMenuServ2 = docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) !== null && _docParagraphMenuServ2 !== void 0 ? _docParagraphMenuServ2 : activeTarget;
18603
+ const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
18721
18604
  if (!latestTarget || latestTarget.kind !== "blockRange" || !latestTarget.blockRange || !(doc === null || doc === void 0 ? void 0 : doc.getBody())) return null;
18722
18605
  const previousBody = doc.getBody();
18723
18606
  const { body, range } = unwrapBlockRangeBody(previousBody, latestTarget.blockRange);
18724
18607
  const actions = buildUnwrapBlockRangeActions(previousBody, body, latestTarget.blockRange);
18725
- const segmentId = (_activeParagraphBound = activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId) !== null && _activeParagraphBound !== void 0 ? _activeParagraphBound : "";
18608
+ const segmentId = (activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId) ?? "";
18726
18609
  if (!await commandService.executeCommand(RichTextEditingMutation.id, {
18727
18610
  unitId: popup.unitId,
18728
18611
  actions,
@@ -18740,12 +18623,11 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18740
18623
  return nextRange;
18741
18624
  };
18742
18625
  const executeParagraphMenuOption = async (option) => {
18743
- var _docParagraphMenuServ3, _ref5, _option$commandId2;
18744
- const latestTarget = (_docParagraphMenuServ3 = docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) !== null && _docParagraphMenuServ3 !== void 0 ? _docParagraphMenuServ3 : activeTarget;
18745
- const targetRange = getTargetSelectionRange(latestTarget, activeParagraphBound !== null && activeParagraphBound !== void 0 ? activeParagraphBound : void 0);
18746
- const blockRange = getBlockSelectionRange(latestTarget, activeParagraphBound !== null && activeParagraphBound !== void 0 ? activeParagraphBound : void 0);
18747
- const formattingRange = getParagraphFormattingRange(latestTarget, activeParagraphBound !== null && activeParagraphBound !== void 0 ? activeParagraphBound : void 0);
18748
- const commandId = (_ref5 = (_option$commandId2 = option.commandId) !== null && _option$commandId2 !== void 0 ? _option$commandId2 : option.id) !== null && _ref5 !== void 0 ? _ref5 : typeof option.label === "string" ? option.label : void 0;
18626
+ const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
18627
+ const targetRange = getTargetSelectionRange(latestTarget, activeParagraphBound ?? void 0);
18628
+ const blockRange = getBlockSelectionRange(latestTarget, activeParagraphBound ?? void 0);
18629
+ const formattingRange = getParagraphFormattingRange(latestTarget, activeParagraphBound ?? void 0);
18630
+ const commandId = option.commandId ?? option.id ?? (typeof option.label === "string" ? option.label : void 0);
18749
18631
  const commandParams = typeof option.params === "function" ? option.params() : option.params;
18750
18632
  if (!commandId) return;
18751
18633
  if (commandId === "doc.menu.paragraph-t.reset-colors") {
@@ -18756,9 +18638,9 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18756
18638
  return;
18757
18639
  }
18758
18640
  if (commandId === "doc.menu.paragraph-t.indent.increase" || commandId === "doc.menu.paragraph-t.indent.decrease") {
18759
- var _paragraphObj$paragra2, _paragraphObj$paragra3;
18641
+ var _paragraphObj$paragra2;
18760
18642
  if (formattingRange) replaceSelection(formattingRange);
18761
- const currentIndent = (_paragraphObj$paragra2 = paragraphObj === null || paragraphObj === void 0 || (_paragraphObj$paragra3 = paragraphObj.paragraphStyle) === null || _paragraphObj$paragra3 === void 0 || (_paragraphObj$paragra3 = _paragraphObj$paragra3.indentFirstLine) === null || _paragraphObj$paragra3 === void 0 ? void 0 : _paragraphObj$paragra3.v) !== null && _paragraphObj$paragra2 !== void 0 ? _paragraphObj$paragra2 : 0;
18643
+ const currentIndent = (paragraphObj === null || paragraphObj === void 0 || (_paragraphObj$paragra2 = paragraphObj.paragraphStyle) === null || _paragraphObj$paragra2 === void 0 || (_paragraphObj$paragra2 = _paragraphObj$paragra2.indentFirstLine) === null || _paragraphObj$paragra2 === void 0 ? void 0 : _paragraphObj$paragra2.v) ?? 0;
18762
18644
  const delta = commandId === "doc.menu.paragraph-t.indent.increase" ? 20 : -20;
18763
18645
  await commandService.executeCommand(DocParagraphSettingCommand.id, { paragraph: { indentFirstLine: { v: Math.max(0, currentIndent + delta) } } });
18764
18646
  finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
@@ -18824,15 +18706,13 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18824
18706
  return;
18825
18707
  }
18826
18708
  const previousTextRanges = shouldRestoreParagraphMenuSelectionAfterCommand(commandId) ? getCurrentTextRangesSnapshot() : null;
18827
- if (commandId && shouldUseInsertBelowRange(commandId, option) && (latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.moveRange)) {
18828
- var _ref6, _targetRange$segmentI;
18829
- docContentInsertService.setInsertRange({
18830
- unitId: popup.unitId,
18831
- startOffset: latestTarget.moveRange.endOffset,
18832
- endOffset: latestTarget.moveRange.endOffset,
18833
- segmentId: (_ref6 = (_targetRange$segmentI = targetRange === null || targetRange === void 0 ? void 0 : targetRange.segmentId) !== null && _targetRange$segmentI !== void 0 ? _targetRange$segmentI : activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId) !== null && _ref6 !== void 0 ? _ref6 : ""
18834
- });
18835
- } else if (PARAGRAPH_MENU_SELECTION_COMMAND_IDS.has(commandId) && !PARAGRAPH_MENU_SKIP_REPLACE_SELECTION_COMMAND_IDS.has(commandId)) replaceSelection(getParagraphMenuCommandTargetRange(commandId, targetRange, formattingRange));
18709
+ if (commandId && shouldUseInsertBelowRange(commandId, option) && (latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.moveRange)) docContentInsertService.setInsertRange({
18710
+ unitId: popup.unitId,
18711
+ startOffset: latestTarget.moveRange.endOffset,
18712
+ endOffset: latestTarget.moveRange.endOffset,
18713
+ segmentId: (targetRange === null || targetRange === void 0 ? void 0 : targetRange.segmentId) ?? (activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId) ?? ""
18714
+ });
18715
+ else if (PARAGRAPH_MENU_SELECTION_COMMAND_IDS.has(commandId) && !PARAGRAPH_MENU_SKIP_REPLACE_SELECTION_COMMAND_IDS.has(commandId)) replaceSelection(getParagraphMenuCommandTargetRange(commandId, targetRange, formattingRange));
18836
18716
  try {
18837
18717
  await executeResolvedCommand({
18838
18718
  ...option,
@@ -18887,14 +18767,14 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18887
18767
  isMouseOver.current = true;
18888
18768
  hoverOpenSchedulerRef.current.openNow();
18889
18769
  },
18890
- children: [/* @__PURE__ */ jsx(TargetIcon, {}), (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.draggable) && /* @__PURE__ */ jsx("button", {
18770
+ children: [/* @__PURE__ */ jsx(TargetIcon, { className: clsx(getParagraphMenuIconSizeClass(targetIconKey), "univer-shrink-0 univer-text-gray-700 dark:!univer-text-white") }), (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.draggable) && /* @__PURE__ */ jsx("button", {
18891
18771
  type: "button",
18892
18772
  className: "univer-group univer-flex univer-h-4 univer-w-2.5 univer-cursor-grab univer-items-center univer-justify-center univer-border-none univer-bg-transparent univer-p-0 active:univer-cursor-grabbing",
18893
18773
  "aria-label": localeService.t("docs-ui.doc.blockMenu.dragBlock"),
18894
18774
  title: localeService.t("docs-ui.doc.blockMenu.dragBlock"),
18895
18775
  onPointerDown: (event) => {
18896
- var _docParagraphMenuServ4, _event$currentTarget$, _event$currentTarget;
18897
- const latestTarget = (_docParagraphMenuServ4 = docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) !== null && _docParagraphMenuServ4 !== void 0 ? _docParagraphMenuServ4 : activeTarget;
18776
+ var _event$currentTarget$, _event$currentTarget;
18777
+ const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
18898
18778
  const moveRange = latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.moveRange;
18899
18779
  if (!moveRange || !(latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.draggable)) return;
18900
18780
  event.preventDefault();
@@ -18909,14 +18789,13 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18909
18789
  setDropRect(null);
18910
18790
  const pointerId = event.pointerId;
18911
18791
  const handlePointerMove = (moveEvent) => {
18912
- var _target$targetOffset, _target$rect;
18913
18792
  if (moveEvent.pointerId !== pointerId) return;
18914
18793
  moveEvent.preventDefault();
18915
18794
  const range = dragRangeRef.current;
18916
18795
  if (!range) return;
18917
18796
  const target = docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.getDropTargetFromClientPoint(moveEvent.clientX, moveEvent.clientY, range);
18918
- dragTargetOffsetRef.current = (_target$targetOffset = target === null || target === void 0 ? void 0 : target.targetOffset) !== null && _target$targetOffset !== void 0 ? _target$targetOffset : null;
18919
- setDropRect((_target$rect = target === null || target === void 0 ? void 0 : target.rect) !== null && _target$rect !== void 0 ? _target$rect : null);
18797
+ dragTargetOffsetRef.current = (target === null || target === void 0 ? void 0 : target.targetOffset) ?? null;
18798
+ setDropRect((target === null || target === void 0 ? void 0 : target.rect) ?? null);
18920
18799
  };
18921
18800
  const finishDrag = (shouldDrop) => {
18922
18801
  window.removeEventListener("pointermove", handlePointerMove);
@@ -18997,6 +18876,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18997
18876
  children: /* @__PURE__ */ jsx(ContextMenuPanel, {
18998
18877
  className: "univer-w-[212px]",
18999
18878
  menuType: resolvedParagraphMenuType,
18879
+ flowQuickGroups: true,
19000
18880
  activeItemIds: (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.kind) === "table" ? void 0 : paragraphMenuActiveItemIds,
19001
18881
  hiddenItemIds: openMode === "slash" || (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.kind) === "table" ? void 0 : paragraphMenuHiddenItemIds,
19002
18882
  autoFocus: openMode === "slash",
@@ -19016,22 +18896,20 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
19016
18896
  finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
19017
18897
  },
19018
18898
  onOptionSelect: async (params) => {
19019
- var _targetRangeRef$curre, _docParagraphMenuServ5;
19020
- const targetRange = (_targetRangeRef$curre = targetRangeRef.current) !== null && _targetRangeRef$curre !== void 0 ? _targetRangeRef$curre : getParagraphMenuTargetRange(activeParagraphBound);
18899
+ const targetRange = targetRangeRef.current ?? getParagraphMenuTargetRange(activeParagraphBound);
19021
18900
  const { commandId, params: commandParams } = getParagraphMenuCommand(params, targetRange);
19022
- const latestTarget = (_docParagraphMenuServ5 = docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) !== null && _docParagraphMenuServ5 !== void 0 ? _docParagraphMenuServ5 : activeTarget;
18901
+ const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
19023
18902
  if ((latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.kind) === "table" && commandId && targetRange) {
19024
- var _targetRange$segmentI2, _targetRange$segmentI3;
19025
18903
  const tableRange = {
19026
18904
  ...targetRange,
19027
- segmentId: (_targetRange$segmentI2 = targetRange.segmentId) !== null && _targetRange$segmentI2 !== void 0 ? _targetRange$segmentI2 : "",
18905
+ segmentId: targetRange.segmentId ?? "",
19028
18906
  collapsed: false
19029
18907
  };
19030
18908
  const afterTableRange = {
19031
18909
  startOffset: latestTarget.moveRange.endOffset,
19032
18910
  endOffset: latestTarget.moveRange.endOffset,
19033
18911
  collapsed: true,
19034
- segmentId: (_targetRange$segmentI3 = targetRange.segmentId) !== null && _targetRange$segmentI3 !== void 0 ? _targetRange$segmentI3 : ""
18912
+ segmentId: targetRange.segmentId ?? ""
19035
18913
  };
19036
18914
  if (commandId === DocCopyCommand.id || commandId === DocCopyCommand.name) {
19037
18915
  await docClipboardService.copy(SliceBodyType.copy, [tableRange]);
@@ -19102,53 +18980,29 @@ function getSectionColumnCount(section) {
19102
18980
  return ((_section$columnProper = section.columnProperties) === null || _section$columnProper === void 0 ? void 0 : _section$columnProper.length) || 1;
19103
18981
  }
19104
18982
  function getSectionColumnGap(section) {
19105
- var _section$columnProper2, _section$columnProper3;
19106
- 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;
18983
+ var _section$columnProper2;
18984
+ return ((_section$columnProper2 = section.columnProperties) === null || _section$columnProper2 === void 0 || (_section$columnProper2 = _section$columnProper2[0]) === null || _section$columnProper2 === void 0 ? void 0 : _section$columnProper2.paddingEnd) ?? DEFAULT_SECTION_COLUMN_GAP;
19107
18985
  }
19108
18986
  function getSectionSettingValues(sections, documentStyle) {
19109
18987
  return {
19110
18988
  columnCount: getCommonValue(sections.map(getSectionColumnCount)),
19111
18989
  columnGap: getCommonValue(sections.map(getSectionColumnGap)),
19112
- separatorType: getCommonValue(sections.map((section) => {
19113
- var _section$columnSepara;
19114
- return (_section$columnSepara = section.columnSeparatorType) !== null && _section$columnSepara !== void 0 ? _section$columnSepara : ColumnSeparatorType.NONE;
19115
- })),
19116
- sectionType: getCommonValue(sections.map((section) => {
19117
- var _section$sectionType;
19118
- return (_section$sectionType = section.sectionType) !== null && _section$sectionType !== void 0 ? _section$sectionType : SectionType.SECTION_TYPE_UNSPECIFIED;
19119
- })),
18990
+ separatorType: getCommonValue(sections.map((section) => section.columnSeparatorType ?? ColumnSeparatorType.NONE)),
18991
+ sectionType: getCommonValue(sections.map((section) => section.sectionType ?? SectionType.SECTION_TYPE_UNSPECIFIED)),
19120
18992
  pageWidth: getCommonValue(sections.map((section) => {
19121
- var _section$pageSize$wid, _section$pageSize, _documentStyle$pageSi;
19122
- 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;
18993
+ var _section$pageSize, _documentStyle$pageSi;
18994
+ return ((_section$pageSize = section.pageSize) === null || _section$pageSize === void 0 ? void 0 : _section$pageSize.width) ?? ((_documentStyle$pageSi = documentStyle.pageSize) === null || _documentStyle$pageSi === void 0 ? void 0 : _documentStyle$pageSi.width);
19123
18995
  })),
19124
18996
  pageHeight: getCommonValue(sections.map((section) => {
19125
- var _section$pageSize$hei, _section$pageSize2, _documentStyle$pageSi2;
19126
- 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;
19127
- })),
19128
- pageOrient: getCommonValue(sections.map((section) => {
19129
- var _section$pageOrient;
19130
- return (_section$pageOrient = section.pageOrient) !== null && _section$pageOrient !== void 0 ? _section$pageOrient : documentStyle.pageOrient;
19131
- })),
19132
- marginTop: getCommonValue(sections.map((section) => {
19133
- var _ref, _section$marginTop;
19134
- return (_ref = (_section$marginTop = section.marginTop) !== null && _section$marginTop !== void 0 ? _section$marginTop : documentStyle.marginTop) !== null && _ref !== void 0 ? _ref : 0;
19135
- })),
19136
- marginBottom: getCommonValue(sections.map((section) => {
19137
- var _ref2, _section$marginBottom;
19138
- return (_ref2 = (_section$marginBottom = section.marginBottom) !== null && _section$marginBottom !== void 0 ? _section$marginBottom : documentStyle.marginBottom) !== null && _ref2 !== void 0 ? _ref2 : 0;
19139
- })),
19140
- marginLeft: getCommonValue(sections.map((section) => {
19141
- var _ref3, _section$marginLeft;
19142
- return (_ref3 = (_section$marginLeft = section.marginLeft) !== null && _section$marginLeft !== void 0 ? _section$marginLeft : documentStyle.marginLeft) !== null && _ref3 !== void 0 ? _ref3 : 0;
19143
- })),
19144
- marginRight: getCommonValue(sections.map((section) => {
19145
- var _ref4, _section$marginRight;
19146
- return (_ref4 = (_section$marginRight = section.marginRight) !== null && _section$marginRight !== void 0 ? _section$marginRight : documentStyle.marginRight) !== null && _ref4 !== void 0 ? _ref4 : 0;
18997
+ var _section$pageSize2, _documentStyle$pageSi2;
18998
+ return ((_section$pageSize2 = section.pageSize) === null || _section$pageSize2 === void 0 ? void 0 : _section$pageSize2.height) ?? ((_documentStyle$pageSi2 = documentStyle.pageSize) === null || _documentStyle$pageSi2 === void 0 ? void 0 : _documentStyle$pageSi2.height);
19147
18999
  })),
19148
- pageNumberStart: getCommonValue(sections.map((section) => {
19149
- var _ref5, _section$pageNumberSt;
19150
- return (_ref5 = (_section$pageNumberSt = section.pageNumberStart) !== null && _section$pageNumberSt !== void 0 ? _section$pageNumberSt : documentStyle.pageNumberStart) !== null && _ref5 !== void 0 ? _ref5 : 1;
19151
- }))
19000
+ pageOrient: getCommonValue(sections.map((section) => section.pageOrient ?? documentStyle.pageOrient)),
19001
+ marginTop: getCommonValue(sections.map((section) => section.marginTop ?? documentStyle.marginTop ?? 0)),
19002
+ marginBottom: getCommonValue(sections.map((section) => section.marginBottom ?? documentStyle.marginBottom ?? 0)),
19003
+ marginLeft: getCommonValue(sections.map((section) => section.marginLeft ?? documentStyle.marginLeft ?? 0)),
19004
+ marginRight: getCommonValue(sections.map((section) => section.marginRight ?? documentStyle.marginRight ?? 0)),
19005
+ pageNumberStart: getCommonValue(sections.map((section) => section.pageNumberStart ?? documentStyle.pageNumberStart ?? 1))
19152
19006
  };
19153
19007
  }
19154
19008
  function createSectionColumnUpdates(sections, documentStyle, change) {
@@ -19163,9 +19017,8 @@ function createSectionColumnUpdates(sections, documentStyle, change) {
19163
19017
  }
19164
19018
  function createSectionOrientationUpdates(sections, documentStyle, pageOrient) {
19165
19019
  return sections.map((section) => {
19166
- var _ref6, _section$pageOrient2, _section$pageSize3;
19167
- const currentOrient = (_ref6 = (_section$pageOrient2 = section.pageOrient) !== null && _section$pageOrient2 !== void 0 ? _section$pageOrient2 : documentStyle.pageOrient) !== null && _ref6 !== void 0 ? _ref6 : PageOrientType.PORTRAIT;
19168
- const currentPageSize = (_section$pageSize3 = section.pageSize) !== null && _section$pageSize3 !== void 0 ? _section$pageSize3 : documentStyle.pageSize;
19020
+ const currentOrient = section.pageOrient ?? documentStyle.pageOrient ?? PageOrientType.PORTRAIT;
19021
+ const currentPageSize = section.pageSize ?? documentStyle.pageSize;
19169
19022
  return {
19170
19023
  sectionId: section.sectionId,
19171
19024
  config: {
@@ -19197,7 +19050,6 @@ function navigateToSection(controller, documentDataModel, sections, sectionId) {
19197
19050
  controller.navigateToSectionEnd(documentDataModel.getUnitId(), index === 0 ? 0 : sections[index - 1].startIndex + 1, sections[index].startIndex);
19198
19051
  }
19199
19052
  function useSectionSetting() {
19200
- var _documentDataModel$ge;
19201
19053
  const commandService = useDependency(ICommandService);
19202
19054
  const instanceService = useDependency(IUniverInstanceService);
19203
19055
  const selectionManager = useDependency(DocSelectionManagerService);
@@ -19205,7 +19057,7 @@ function useSectionSetting() {
19205
19057
  const documentDataModel = useObservable(useMemo(() => instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), [instanceService]));
19206
19058
  const resolveSections = () => (documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getDocumentStyle().documentFlavor) === DocumentFlavor.TRADITIONAL ? getSelectedSections(documentDataModel, selectionManager.getDocRanges()) : [];
19207
19059
  const sections = useObservable(documentDataModel ? () => combineLatest([selectionManager.textSelection$.pipe(startWith(void 0)), documentDataModel.change$.pipe(startWith(void 0))]).pipe(map(resolveSections)) : null, resolveSections(), false, [documentDataModel, selectionManager]);
19208
- const documentStyle = (_documentDataModel$ge = documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getDocumentStyle()) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : {};
19060
+ const documentStyle = (documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getDocumentStyle()) ?? {};
19209
19061
  const values = getSectionSettingValues(sections, documentStyle);
19210
19062
  const body = documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getBody();
19211
19063
  const allSections = (documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getDocumentStyle().documentFlavor) === DocumentFlavor.TRADITIONAL && body ? getTopLevelSectionBreaks(body) : [];
@@ -19230,7 +19082,7 @@ function useSectionSetting() {
19230
19082
  selectedSectionId: sections.length === 1 ? sections[0].sectionId : void 0,
19231
19083
  ...values,
19232
19084
  selectSection(sectionId) {
19233
- navigateToSection(controller, documentDataModel !== null && documentDataModel !== void 0 ? documentDataModel : void 0, allSections, sectionId);
19085
+ navigateToSection(controller, documentDataModel ?? void 0, allSections, sectionId);
19234
19086
  },
19235
19087
  setColumnCount(value) {
19236
19088
  const next = Math.max(1, Math.round(value));
@@ -19303,7 +19155,6 @@ function SettingRow(props) {
19303
19155
  });
19304
19156
  }
19305
19157
  function SectionSetting() {
19306
- var _setting$selectedSect;
19307
19158
  const localeService = useDependency(LocaleService);
19308
19159
  const controller = useDependency(DocSectionSettingController);
19309
19160
  const setting = useSectionSetting();
@@ -19324,7 +19175,7 @@ function SectionSetting() {
19324
19175
  label: localeService.t("docs-ui.doc.slider.sectionSetting"),
19325
19176
  children: /* @__PURE__ */ jsx(Select, {
19326
19177
  className: "univer-w-full",
19327
- value: (_setting$selectedSect = setting.selectedSectionId) !== null && _setting$selectedSect !== void 0 ? _setting$selectedSect : "",
19178
+ value: setting.selectedSectionId ?? "",
19328
19179
  options: [...setting.selectedSectionId == null ? [{
19329
19180
  label: localeService.t("docs-ui.doc.sectionSetting.multipleValues"),
19330
19181
  value: "",
@@ -19883,11 +19734,10 @@ const COLLAB_CURSOR_LABEL_MAX_WIDTH = 200;
19883
19734
  const COLLAB_CURSOR_LABEL_TEXT_PADDING_LR = 6;
19884
19735
  const COLLAB_CURSOR_LABEL_TEXT_PADDING_TB = 4;
19885
19736
  function drawBubble(ctx, props) {
19886
- var _radius, _width, _height;
19887
19737
  let { radius, width, height } = props;
19888
- radius = (_radius = radius) !== null && _radius !== void 0 ? _radius : 0;
19889
- width = (_width = width) !== null && _width !== void 0 ? _width : 30;
19890
- height = (_height = height) !== null && _height !== void 0 ? _height : 30;
19738
+ radius = radius ?? 0;
19739
+ width = width ?? 30;
19740
+ height = height ?? 30;
19891
19741
  let bottomRight = 0;
19892
19742
  bottomRight = Math.min(radius, width / 2, height / 2);
19893
19743
  ctx.beginPath();
@@ -19984,7 +19834,7 @@ function checkCreateHeaderFooterType(viewModel, editArea, segmentPage, page) {
19984
19834
  const [headerFooterId, createType] = useFirstPageHeaderFooter === BooleanNumber.TRUE && isFirstPage ? variants.first : evenAndOddHeaders === BooleanNumber.TRUE && isEvenPage ? variants.even : variants.default;
19985
19835
  return {
19986
19836
  createType: headerFooterId ? null : createType,
19987
- headerFooterId: headerFooterId !== null && headerFooterId !== void 0 ? headerFooterId : null,
19837
+ headerFooterId: headerFooterId ?? null,
19988
19838
  sectionId
19989
19839
  };
19990
19840
  }
@@ -20235,18 +20085,14 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20235
20085
  if (!updateCommandList.includes(command.id)) return;
20236
20086
  const param = command.params;
20237
20087
  switch (command.id) {
20238
- case MoveCursorOperation.id:
20239
- var _param$granularity;
20240
- return this._handleMoveCursor(param.direction, (_param$granularity = param.granularity) !== null && _param$granularity !== void 0 ? _param$granularity : "character");
20241
- case MoveSelectionOperation.id:
20242
- var _param$granularity2;
20243
- return this._handleShiftMoveSelection(param.direction, (_param$granularity2 = param.granularity) !== null && _param$granularity2 !== void 0 ? _param$granularity2 : "character");
20088
+ case MoveCursorOperation.id: return this._handleMoveCursor(param.direction, param.granularity ?? "character");
20089
+ case MoveSelectionOperation.id: return this._handleShiftMoveSelection(param.direction, param.granularity ?? "character");
20244
20090
  default: throw new Error("Unknown command");
20245
20091
  }
20246
20092
  }));
20247
20093
  }
20248
20094
  _handleShiftMoveSelection(direction, granularity = "character") {
20249
- var _docDataModel$getSelf, _body$dataStream$leng, _docDataModel$getCust;
20095
+ var _docDataModel$getSelf;
20250
20096
  const activeRange = this._textSelectionManagerService.getActiveTextRange();
20251
20097
  const allRanges = this._textSelectionManagerService.getTextRanges();
20252
20098
  const docDataModel = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
@@ -20256,8 +20102,8 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20256
20102
  const docObject = currentRender ? neoGetDocObject(currentRender) : null;
20257
20103
  if (activeRange == null || skeleton == null || docObject == null) return;
20258
20104
  const { startOffset, endOffset, style, collapsed, direction: rangeDirection, segmentId, startNodePosition, endNodePosition, segmentPage } = activeRange;
20259
- const normalizedSegmentId = segmentId !== null && segmentId !== void 0 ? segmentId : "";
20260
- const normalizedSegmentPage = segmentPage !== null && segmentPage !== void 0 ? segmentPage : -1;
20105
+ const normalizedSegmentId = segmentId ?? "";
20106
+ const normalizedSegmentPage = segmentPage ?? -1;
20261
20107
  if (allRanges.length > 1) {
20262
20108
  let min = Number.POSITIVE_INFINITY;
20263
20109
  let max = Number.NEGATIVE_INFINITY;
@@ -20276,8 +20122,8 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20276
20122
  let focusOffset = collapsed ? endOffset : rangeDirection === RANGE_DIRECTION.FORWARD ? endOffset : startOffset;
20277
20123
  const body = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
20278
20124
  if (body == null) return;
20279
- const dataStreamLength = (_body$dataStream$leng = body.dataStream.length) !== null && _body$dataStream$leng !== void 0 ? _body$dataStream$leng : Number.POSITIVE_INFINITY;
20280
- const customRanges = (_docDataModel$getCust = docDataModel.getCustomRanges()) !== null && _docDataModel$getCust !== void 0 ? _docDataModel$getCust : [];
20125
+ const dataStreamLength = body.dataStream.length ?? Number.POSITIVE_INFINITY;
20126
+ const customRanges = docDataModel.getCustomRanges() ?? [];
20281
20127
  if (granularity !== "character") {
20282
20128
  const nextOffset = this._getCursorOffsetByGranularity(skeleton, focusOffset, direction, granularity, normalizedSegmentId, normalizedSegmentPage, dataStreamLength, body.dataStream);
20283
20129
  if (nextOffset == null || nextOffset === focusOffset) return;
@@ -20292,10 +20138,9 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20292
20138
  return;
20293
20139
  }
20294
20140
  if (direction === Direction.LEFT || direction === Direction.RIGHT) {
20295
- var _preGlyph$count;
20296
20141
  const preGlyph = skeleton.findNodeByCharIndex(focusOffset - 1, segmentId, segmentPage);
20297
20142
  const curGlyph = skeleton.findNodeByCharIndex(focusOffset, segmentId, segmentPage);
20298
- focusOffset = direction === 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);
20143
+ focusOffset = direction === Direction.RIGHT ? focusOffset + curGlyph.count : focusOffset - ((preGlyph === null || preGlyph === void 0 ? void 0 : preGlyph.count) ?? 0);
20299
20144
  focusOffset = Math.min(dataStreamLength - 2, Math.max(0, focusOffset));
20300
20145
  this._textSelectionManagerService.replaceDocRanges([{
20301
20146
  startOffset: anchorOffset,
@@ -20330,7 +20175,7 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20330
20175
  }
20331
20176
  }
20332
20177
  _handleMoveCursor(direction, granularity = "character") {
20333
- var _docDataModel$getSelf2, _body$dataStream$leng2, _docDataModel$getCust2;
20178
+ var _docDataModel$getSelf2;
20334
20179
  const activeRange = this._textSelectionManagerService.getActiveTextRange();
20335
20180
  const allRanges = this._textSelectionManagerService.getTextRanges();
20336
20181
  const docDataModel = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
@@ -20340,12 +20185,12 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20340
20185
  const docObject = currentRender ? neoGetDocObject(currentRender) : null;
20341
20186
  if (activeRange == null || skeleton == null || docObject == null || allRanges == null) return;
20342
20187
  const { startOffset, endOffset, style, collapsed, segmentId, startNodePosition, endNodePosition, segmentPage } = activeRange;
20343
- const normalizedSegmentId = segmentId !== null && segmentId !== void 0 ? segmentId : "";
20344
- const normalizedSegmentPage = segmentPage !== null && segmentPage !== void 0 ? segmentPage : -1;
20188
+ const normalizedSegmentId = segmentId ?? "";
20189
+ const normalizedSegmentPage = segmentPage ?? -1;
20345
20190
  const body = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
20346
20191
  if (body == null) return;
20347
- const dataStreamLength = (_body$dataStream$leng2 = body.dataStream.length) !== null && _body$dataStream$leng2 !== void 0 ? _body$dataStream$leng2 : Number.POSITIVE_INFINITY;
20348
- const customRanges = (_docDataModel$getCust2 = docDataModel.getCustomRanges()) !== null && _docDataModel$getCust2 !== void 0 ? _docDataModel$getCust2 : [];
20192
+ const dataStreamLength = body.dataStream.length ?? Number.POSITIVE_INFINITY;
20193
+ const customRanges = docDataModel.getCustomRanges() ?? [];
20349
20194
  if (granularity !== "character") {
20350
20195
  let cursorOffset;
20351
20196
  if (!activeRange.collapsed || allRanges.length > 1) {
@@ -20383,10 +20228,8 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20383
20228
  const preSpan = skeleton.findNodeByCharIndex(startOffset - 1, segmentId, segmentPage);
20384
20229
  const curSpan = skeleton.findNodeByCharIndex(startOffset, segmentId, segmentPage);
20385
20230
  const nextGlyph = skeleton.findNodeByCharIndex(startOffset + 1, segmentId, segmentPage);
20386
- if (direction === Direction.LEFT) {
20387
- var _preSpan$count;
20388
- cursor = Math.max(0, startOffset - ((_preSpan$count = preSpan === null || preSpan === void 0 ? void 0 : preSpan.count) !== null && _preSpan$count !== void 0 ? _preSpan$count : 1));
20389
- } else cursor = Math.min(dataStreamLength - 2, endOffset + curSpan.count + ((nextGlyph === null || nextGlyph === void 0 ? void 0 : nextGlyph.streamType) === DataStreamTreeTokenType.SECTION_BREAK ? 1 : 0));
20231
+ if (direction === Direction.LEFT) cursor = Math.max(0, startOffset - ((preSpan === null || preSpan === void 0 ? void 0 : preSpan.count) ?? 1));
20232
+ else cursor = Math.min(dataStreamLength - 2, endOffset + curSpan.count + ((nextGlyph === null || nextGlyph === void 0 ? void 0 : nextGlyph.streamType) === DataStreamTreeTokenType.SECTION_BREAK ? 1 : 0));
20390
20233
  }
20391
20234
  const skipTokens = [...this._getCursorSkipTokens()];
20392
20235
  if (direction === Direction.LEFT) while (skipTokens.includes(body.dataStream[cursor])) cursor--;
@@ -20457,9 +20300,8 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20457
20300
  return 0;
20458
20301
  }
20459
20302
  _getWordBoundaryOffset(skeleton, focusOffset, direction, segmentId, segmentPage, dataStreamLength) {
20460
- var _skeleton$findNodeByC;
20461
20303
  if (direction !== Direction.LEFT && direction !== Direction.RIGHT) return;
20462
- const glyph = (_skeleton$findNodeByC = skeleton.findNodeByCharIndex(focusOffset, segmentId, segmentPage)) !== null && _skeleton$findNodeByC !== void 0 ? _skeleton$findNodeByC : skeleton.findNodeByCharIndex(Math.max(0, focusOffset - 1), segmentId, segmentPage);
20304
+ const glyph = skeleton.findNodeByCharIndex(focusOffset, segmentId, segmentPage) ?? skeleton.findNodeByCharIndex(Math.max(0, focusOffset - 1), segmentId, segmentPage);
20463
20305
  if (glyph == null) return direction === Direction.LEFT ? 0 : dataStreamLength - 2;
20464
20306
  const paragraphInfo = getParagraphInfoByGlyph(glyph);
20465
20307
  if (paragraphInfo == null) return;
@@ -20469,9 +20311,9 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20469
20311
  return Math.min(dataStreamLength - 2, Math.max(0, nextOffset));
20470
20312
  }
20471
20313
  _getLineBoundaryOffset(skeleton, focusOffset, direction, segmentId, segmentPage, dataStreamLength) {
20472
- var _skeleton$findNodeByC2, _glyph$parent;
20314
+ var _glyph$parent;
20473
20315
  if (direction !== Direction.LEFT && direction !== Direction.RIGHT) return;
20474
- const glyph = (_skeleton$findNodeByC2 = skeleton.findNodeByCharIndex(focusOffset, segmentId, segmentPage)) !== null && _skeleton$findNodeByC2 !== void 0 ? _skeleton$findNodeByC2 : skeleton.findNodeByCharIndex(Math.max(0, focusOffset - 1), segmentId, segmentPage);
20316
+ const glyph = skeleton.findNodeByCharIndex(focusOffset, segmentId, segmentPage) ?? skeleton.findNodeByCharIndex(Math.max(0, focusOffset - 1), segmentId, segmentPage);
20475
20317
  const line = glyph === null || glyph === void 0 || (_glyph$parent = glyph.parent) === null || _glyph$parent === void 0 ? void 0 : _glyph$parent.parent;
20476
20318
  if (line == null) return direction === Direction.LEFT ? 0 : dataStreamLength - 2;
20477
20319
  const boundaryGlyph = direction === Direction.LEFT ? this._getFirstCursorGlyphInLine(line) : this._getLastCursorGlyphInLine(line);
@@ -20581,7 +20423,6 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20581
20423
  return divideLeft + left;
20582
20424
  }
20583
20425
  _matchPositionByLeftOffset(docSkeleton, line, offsetLeft, nodePosition) {
20584
- var _nearestNode$glyph;
20585
20426
  const nearestNode = { distance: Number.POSITIVE_INFINITY };
20586
20427
  const nearestEmptyParagraphNode = { distance: Number.POSITIVE_INFINITY };
20587
20428
  for (const divide of line.divides) {
@@ -20608,7 +20449,7 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20608
20449
  }
20609
20450
  }
20610
20451
  }
20611
- const nearestGlyph = (_nearestNode$glyph = nearestNode.glyph) !== null && _nearestNode$glyph !== void 0 ? _nearestNode$glyph : nearestEmptyParagraphNode.glyph;
20452
+ const nearestGlyph = nearestNode.glyph ?? nearestEmptyParagraphNode.glyph;
20612
20453
  if (nearestGlyph == null) return;
20613
20454
  const { segmentPage } = nodePosition;
20614
20455
  return docSkeleton.findPositionByGlyph(nearestGlyph, segmentPage);
@@ -20763,10 +20604,10 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20763
20604
  }
20764
20605
  }
20765
20606
  _findLineAroundTable(table, direction) {
20766
- var _pages, _tablePage$parent;
20607
+ var _tablePage$parent;
20767
20608
  const tablePage = table.parent;
20768
20609
  if (tablePage == null) return;
20769
- const pages = (_pages = (_tablePage$parent = tablePage.parent) === null || _tablePage$parent === void 0 ? void 0 : _tablePage$parent.pages) !== null && _pages !== void 0 ? _pages : [tablePage];
20610
+ const pages = ((_tablePage$parent = tablePage.parent) === null || _tablePage$parent === void 0 ? void 0 : _tablePage$parent.pages) ?? [tablePage];
20770
20611
  const lineMatcher = direction ? (line) => line.st === table.ed + 1 : (line) => line.ed === table.st - 1;
20771
20612
  for (const page of pages) for (const section of page.sections) for (const column of section.columns) {
20772
20613
  const line = (direction ? column.lines : [...column.lines].reverse()).find(lineMatcher);
@@ -20780,14 +20621,12 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20780
20621
  return Math.min(Math.abs(offsetLeft - left), Math.abs(offsetLeft - right));
20781
20622
  }
20782
20623
  _getTableCellHostOffsetLeft(cell) {
20783
- var _table$left, _cell$left, _cell$marginLeft;
20784
20624
  const row = cell.parent;
20785
20625
  const table = row === null || row === void 0 ? void 0 : row.parent;
20786
- return ((_table$left = table === null || table === void 0 ? void 0 : table.left) !== null && _table$left !== void 0 ? _table$left : 0) + ((_cell$left = cell.left) !== null && _cell$left !== void 0 ? _cell$left : 0) + ((_cell$marginLeft = cell.marginLeft) !== null && _cell$marginLeft !== void 0 ? _cell$marginLeft : 0);
20626
+ return ((table === null || table === void 0 ? void 0 : table.left) ?? 0) + (cell.left ?? 0) + (cell.marginLeft ?? 0);
20787
20627
  }
20788
20628
  _getTableCellContentWidth(cell) {
20789
- var _cell$pageWidth, _cell$marginLeft2, _cell$marginRight;
20790
- return Math.max(0, ((_cell$pageWidth = cell.pageWidth) !== null && _cell$pageWidth !== void 0 ? _cell$pageWidth : 0) - ((_cell$marginLeft2 = cell.marginLeft) !== null && _cell$marginLeft2 !== void 0 ? _cell$marginLeft2 : 0) - ((_cell$marginRight = cell.marginRight) !== null && _cell$marginRight !== void 0 ? _cell$marginRight : 0));
20629
+ return Math.max(0, (cell.pageWidth ?? 0) - (cell.marginLeft ?? 0) - (cell.marginRight ?? 0));
20791
20630
  }
20792
20631
  _isTableCellContentPage(page) {
20793
20632
  var _table$rows;
@@ -20828,8 +20667,8 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
20828
20667
  };
20829
20668
  }
20830
20669
  _findColumnGroupByBlockLine(page, line) {
20831
- var _page$skeColumnGroups, _page$skeColumnGroups2;
20832
- for (const columnGroup of (_page$skeColumnGroups = (_page$skeColumnGroups2 = page.skeColumnGroups) === null || _page$skeColumnGroups2 === void 0 ? void 0 : _page$skeColumnGroups2.values()) !== null && _page$skeColumnGroups !== void 0 ? _page$skeColumnGroups : []) if (line.paragraphIndex === columnGroup.ed || line.st <= columnGroup.ed && line.ed >= columnGroup.st) return columnGroup;
20670
+ var _page$skeColumnGroups;
20671
+ for (const columnGroup of ((_page$skeColumnGroups = page.skeColumnGroups) === null || _page$skeColumnGroups === void 0 ? void 0 : _page$skeColumnGroups.values()) ?? []) if (line.paragraphIndex === columnGroup.ed || line.st <= columnGroup.ed && line.ed >= columnGroup.st) return columnGroup;
20833
20672
  }
20834
20673
  _findColumnGroupBlockLine(columnGroup) {
20835
20674
  const page = columnGroup.parent;
@@ -20988,7 +20827,7 @@ let DocClipboardController = class DocClipboardController extends RxDisposable {
20988
20827
  _initLegacyPasteCommand() {
20989
20828
  var _this$_docSelectionRe;
20990
20829
  (_this$_docSelectionRe = this._docSelectionRenderService) === null || _this$_docSelectionRe === void 0 || _this$_docSelectionRe.onPaste$.pipe(takeUntil(this.dispose$)).subscribe((config) => {
20991
- var _clipboardEvent$clipb, _clipboardEvent$clipb2, _clipboardEvent$clipb3, _clipboardEvent$clipb4, _htmlContent;
20830
+ var _clipboardEvent$clipb, _clipboardEvent$clipb2, _clipboardEvent$clipb3, _clipboardEvent$clipb4;
20992
20831
  if (!whenDocOrEditor(this._contextService)) return;
20993
20832
  config.event.preventDefault();
20994
20833
  const clipboardEvent = config.event;
@@ -20996,7 +20835,7 @@ let DocClipboardController = class DocClipboardController extends RxDisposable {
20996
20835
  const internalJson = (_clipboardEvent$clipb2 = clipboardEvent.clipboardData) === null || _clipboardEvent$clipb2 === void 0 ? void 0 : _clipboardEvent$clipb2.getData("application/x-doc-fragment+json");
20997
20836
  const textContent = (_clipboardEvent$clipb3 = clipboardEvent.clipboardData) === null || _clipboardEvent$clipb3 === void 0 ? void 0 : _clipboardEvent$clipb3.getData(PLAIN_TEXT_CLIPBOARD_MIME_TYPE);
20998
20837
  const files = [...((_clipboardEvent$clipb4 = clipboardEvent.clipboardData) === null || _clipboardEvent$clipb4 === void 0 ? void 0 : _clipboardEvent$clipb4.items) || []].filter((item) => imageMimeTypeSet.has(item.type)).map((item) => item.getAsFile()).filter((e) => !!e);
20999
- if (!!this._editorService.getEditor(this._context.unitId) && ((_htmlContent = htmlContent) !== null && _htmlContent !== void 0 ? _htmlContent : "").indexOf("</table>") > -1) htmlContent = "";
20838
+ if (!!this._editorService.getEditor(this._context.unitId) && (htmlContent ?? "").indexOf("</table>") > -1) htmlContent = "";
21000
20839
  this._docClipboardService.legacyPaste({
21001
20840
  html: htmlContent,
21002
20841
  internalJson,
@@ -21054,10 +20893,10 @@ let DocContextMenuRenderController = class DocContextMenuRenderController extend
21054
20893
  }));
21055
20894
  }
21056
20895
  _isSelectionInCodeBlock() {
21057
- var _documentDataModel$ge, _documentDataModel$ge2, _this$_docSelectionMa;
20896
+ var _documentDataModel$ge;
21058
20897
  const documentDataModel = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
21059
- const blockRanges = (_documentDataModel$ge = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 || (_documentDataModel$ge2 = _documentDataModel$ge2.blockRanges) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.filter((range) => range.blockType === DocumentBlockRangeType.CODE)) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : [];
21060
- const textRanges = (_this$_docSelectionMa = this._docSelectionManagerService.getTextRanges()) !== null && _this$_docSelectionMa !== void 0 ? _this$_docSelectionMa : [];
20898
+ const blockRanges = (documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getBody()) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.blockRanges) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.filter((range) => range.blockType === DocumentBlockRangeType.CODE)) ?? [];
20899
+ const textRanges = this._docSelectionManagerService.getTextRanges() ?? [];
21061
20900
  if (!blockRanges.length || !textRanges.length) return false;
21062
20901
  return blockRanges.some((blockRange) => textRanges.some((range) => isRangeIntersectingBlock(range, blockRange.startIndex, blockRange.endIndex)));
21063
20902
  }
@@ -21320,7 +21159,7 @@ let DocInputController = class DocInputController extends Disposable {
21320
21159
  }
21321
21160
  _initialNormalInput() {
21322
21161
  this._onInputSubscription = this._docSelectionRenderService.onInput$.subscribe(async (config) => {
21323
- var _docDataModel$getSelf, _originBody$customRan, _originBody$customDec;
21162
+ var _docDataModel$getSelf;
21324
21163
  if (config == null) return;
21325
21164
  const { unitId } = this._context;
21326
21165
  const { event, content = "", activeRange } = config;
@@ -21334,9 +21173,9 @@ let DocInputController = class DocInputController extends Disposable {
21334
21173
  if (!originBody) return;
21335
21174
  const defaultTextStyle = this._docMenuStyleService.getDefaultStyle();
21336
21175
  const cacheStyle = this._docMenuStyleService.getStyleCache();
21337
- const curCustomRange = getCustomRangeAtPosition((_originBody$customRan = originBody === null || originBody === void 0 ? void 0 : originBody.customRanges) !== null && _originBody$customRan !== void 0 ? _originBody$customRan : [], activeRange.endOffset, SHEET_EDITOR_UNITS.includes(unitId));
21176
+ const curCustomRange = getCustomRangeAtPosition((originBody === null || originBody === void 0 ? void 0 : originBody.customRanges) ?? [], activeRange.endOffset, SHEET_EDITOR_UNITS.includes(unitId));
21338
21177
  const curTextRun = getTextRunAtPosition(originBody, activeRange.endOffset, defaultTextStyle, cacheStyle, SHEET_EDITOR_UNITS.includes(unitId));
21339
- const curCustomDecorations = getCustomDecorationAtPosition((_originBody$customDec = originBody === null || originBody === void 0 ? void 0 : originBody.customDecorations) !== null && _originBody$customDec !== void 0 ? _originBody$customDec : [], activeRange.endOffset);
21178
+ const curCustomDecorations = getCustomDecorationAtPosition((originBody === null || originBody === void 0 ? void 0 : originBody.customDecorations) ?? [], activeRange.endOffset);
21340
21179
  await this._commandService.executeCommand(InsertTextCommand.id, {
21341
21180
  unitId,
21342
21181
  body: {
@@ -21464,11 +21303,12 @@ let DocSelectionRenderController = class DocSelectionRenderController extends Di
21464
21303
  scene.resetCursor();
21465
21304
  }));
21466
21305
  this.disposeWithMe(document.onPointerDown$.subscribeEvent((evt, state) => {
21306
+ var _this$_editorService$;
21467
21307
  if (this._isEditorReadOnly(unitId)) return;
21468
21308
  if (this._isEmbedInteractionEvent(evt, unitId)) return;
21469
21309
  const docDataModel = this._instanceSrv.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
21470
21310
  if ((docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId()) !== unitId) this._instanceSrv.setCurrentUnitForType(unitId);
21471
- this._instanceSrv.focusUnit(unitId);
21311
+ if (!((_this$_editorService$ = this._editorService.getEditorRenderConfig(unitId)) === null || _this$_editorService$ === void 0 ? void 0 : _this$_editorService$.preserveHostFocus)) this._instanceSrv.focusUnit(unitId);
21472
21312
  const skeleton = this._docSkeletonManagerService.getSkeleton();
21473
21313
  const { offsetX, offsetY } = evt;
21474
21314
  const coord = this._getTransformCoordForDocumentOffset(offsetX, offsetY);
@@ -21802,10 +21642,7 @@ let DocsRenderService = class DocsRenderService extends RxDisposable {
21802
21642
  this._init();
21803
21643
  }
21804
21644
  _init() {
21805
- this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_DOC).forEach((documentModel) => {
21806
- var _this$_instanceSrv$ge;
21807
- return this._createRenderer(documentModel, (_this$_instanceSrv$ge = this._instanceSrv.getUnitCreateOptions(documentModel.getUnitId())) !== null && _this$_instanceSrv$ge !== void 0 ? _this$_instanceSrv$ge : void 0);
21808
- });
21645
+ this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_DOC).forEach((documentModel) => this._createRenderer(documentModel, this._instanceSrv.getUnitCreateOptions(documentModel.getUnitId()) ?? void 0));
21809
21646
  this._instanceSrv.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((event) => this._createRenderer(event.unit, event.options));
21810
21647
  this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((doc) => this._disposeRenderer(doc));
21811
21648
  }
@@ -22245,17 +22082,17 @@ UniverDocsUIPlugin = __decorate([
22245
22082
  //#endregion
22246
22083
  //#region src/views/rich-text-editor/hooks/editor-undo-redo-keyboard.ts
22247
22084
  function isSheetFormulaEditor(editorUnitId, univerInstanceService) {
22248
- var _documentModel$getBod, _documentModel$getBod2;
22085
+ var _documentModel$getBod;
22249
22086
  if (editorUnitId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY && editorUnitId !== DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) return false;
22250
22087
  const documentModel = univerInstanceService.getUnit(editorUnitId, UniverInstanceType.UNIVER_DOC);
22251
- return (_documentModel$getBod = documentModel === null || documentModel === void 0 || (_documentModel$getBod2 = documentModel.getBody()) === null || _documentModel$getBod2 === void 0 || (_documentModel$getBod2 = _documentModel$getBod2.dataStream) === null || _documentModel$getBod2 === void 0 ? void 0 : _documentModel$getBod2.startsWith("=")) !== null && _documentModel$getBod !== void 0 ? _documentModel$getBod : false;
22088
+ return (documentModel === null || documentModel === void 0 || (_documentModel$getBod = documentModel.getBody()) === null || _documentModel$getBod === void 0 || (_documentModel$getBod = _documentModel$getBod.dataStream) === null || _documentModel$getBod === void 0 ? void 0 : _documentModel$getBod.startsWith("=")) ?? false;
22252
22089
  }
22253
22090
  function executeEditorUndoRedoCommand(options) {
22254
- var _univerInstanceServic, _univerInstanceServic2;
22091
+ var _univerInstanceServic;
22255
22092
  const { commandId, commandService, editorUnitId, univerInstanceService } = options;
22256
22093
  const shouldUseSheetEditorContext = editorUnitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY || editorUnitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;
22257
22094
  if (isSheetFormulaEditor(editorUnitId, univerInstanceService)) return;
22258
- const previousFocusedUnitId = (_univerInstanceServic = (_univerInstanceServic2 = univerInstanceService.getFocusedUnit()) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getUnitId()) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : null;
22095
+ const previousFocusedUnitId = ((_univerInstanceServic = univerInstanceService.getFocusedUnit()) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId()) ?? null;
22259
22096
  const shouldRestoreFocus = !shouldUseSheetEditorContext && previousFocusedUnitId !== null && previousFocusedUnitId !== editorUnitId;
22260
22097
  if (!shouldUseSheetEditorContext && previousFocusedUnitId !== editorUnitId) univerInstanceService.focusUnit(editorUnitId);
22261
22098
  commandService.executeCommand(commandId).finally(() => {
@@ -22283,7 +22120,7 @@ function createEditorUndoRedoKeyboardConfig(options) {
22283
22120
  ...keyCodes
22284
22121
  ],
22285
22122
  handler: (keyCode, metaKey) => {
22286
- switch (`${keyCode}:${metaKey !== null && metaKey !== void 0 ? metaKey : 0}`) {
22123
+ switch (`${keyCode}:${metaKey ?? 0}`) {
22287
22124
  case `${KeyCode.Z}:${ctrlCommand}`:
22288
22125
  executeEditorUndoRedoCommand({
22289
22126
  commandId: UndoCommand.id,
@@ -22310,8 +22147,8 @@ function createEditorUndoRedoKeyboardConfig(options) {
22310
22147
  //#endregion
22311
22148
  //#region src/views/rich-text-editor/hooks/use-editor.ts
22312
22149
  function useEditor(opts) {
22313
- const { editorId, initialValue, container, autoFocus: _autoFocus, isSingle, canvasStyle } = opts;
22314
- const autoFocus = useMemo(() => _autoFocus !== null && _autoFocus !== void 0 ? _autoFocus : false, []);
22150
+ const { editorId, initialValue, container, preserveHostFocus, autoFocus: _autoFocus, isSingle, canvasStyle } = opts;
22151
+ const autoFocus = useMemo(() => _autoFocus ?? false, []);
22315
22152
  const [editor, setEditor] = useState();
22316
22153
  const editorService = useDependency(IEditorService);
22317
22154
  useLayoutEffect(() => {
@@ -22343,14 +22180,15 @@ function useEditor(opts) {
22343
22180
  autofocus: true,
22344
22181
  canvasStyle,
22345
22182
  editorUnitId: editorId,
22346
- initialSnapshot: snapshot
22183
+ initialSnapshot: snapshot,
22184
+ preserveHostFocus
22347
22185
  }, container.current);
22348
22186
  const editor = editorService.getEditor(editorId);
22349
22187
  setEditor(editor);
22350
22188
  if (autoFocus) {
22351
- var _snapshot$body$dataSt, _snapshot$body;
22189
+ var _snapshot$body;
22352
22190
  editorService.focus(editorId);
22353
- const end = ((_snapshot$body$dataSt = (_snapshot$body = snapshot.body) === null || _snapshot$body === void 0 ? void 0 : _snapshot$body.dataStream.length) !== null && _snapshot$body$dataSt !== void 0 ? _snapshot$body$dataSt : 2) - 2;
22191
+ const end = (((_snapshot$body = snapshot.body) === null || _snapshot$body === void 0 ? void 0 : _snapshot$body.dataStream.length) ?? 2) - 2;
22354
22192
  editor.setSelectionRanges([{
22355
22193
  startOffset: end,
22356
22194
  endOffset: end
@@ -22408,11 +22246,10 @@ const useEditorClickOutside = (editorId, containerRef, onClickOutside) => {
22408
22246
  * limitations under the License.
22409
22247
  */
22410
22248
  function useIsFocusing(editorId) {
22411
- var _docSelectionRenderSe;
22412
22249
  const renderer = useDependency(IRenderManagerService).getRenderUnitById(editorId);
22413
22250
  const docSelectionRenderService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocSelectionRenderService);
22414
22251
  const selections = useObservable(docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.textSelectionInner$);
22415
- 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)));
22252
+ return Boolean(((docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing) ?? false) && (selections === null || selections === void 0 ? void 0 : selections.textRanges.some((r) => r.collapsed)));
22416
22253
  }
22417
22254
 
22418
22255
  //#endregion
@@ -22553,10 +22390,10 @@ function useOnChange(editor, onChange) {
22553
22390
  if (!editor) return;
22554
22391
  const dispose = commandService.onCommandExecuted((command) => {
22555
22392
  if (command.id === RichTextEditingMutation.id) {
22556
- var _data$body$dataStream, _data$body;
22393
+ var _data$body;
22557
22394
  if (command.params.unitId !== editor.getEditorId()) return;
22558
22395
  const data = editor.getDocumentData();
22559
- onChange(data, getPlainText((_data$body$dataStream = (_data$body = data.body) === null || _data$body === void 0 ? void 0 : _data$body.dataStream) !== null && _data$body$dataStream !== void 0 ? _data$body$dataStream : ""));
22396
+ onChange(data, getPlainText(((_data$body = data.body) === null || _data$body === void 0 ? void 0 : _data$body.dataStream) ?? ""));
22560
22397
  }
22561
22398
  });
22562
22399
  return () => {
@@ -22698,8 +22535,7 @@ const useResize = (editor, isSingle = true, autoScrollbar, autoScroll) => {
22698
22535
  //#endregion
22699
22536
  //#region src/views/RichTextEditor.tsx
22700
22537
  const RichTextEditor = (props) => {
22701
- var _docSelectionRenderSe3;
22702
- const { className, autoFocus, onFocusChange: _onFocusChange, initialValue, onClickOutside: _onClickOutside, keyboardEventConfig, moveCursor = true, style, isSingle, editorId: propsEditorId, onHeightChange, onChange: _onChange, defaultHeight = 32, maxHeight = 32, icon, editorRef, placeholder, noStyle } = props;
22538
+ const { className, autoFocus, onFocusChange: _onFocusChange, initialValue, onClickOutside: _onClickOutside, preserveHostFocus, keyboardEventConfig, moveCursor = true, style, isSingle, editorId: propsEditorId, onHeightChange, onChange: _onChange, defaultHeight = 32, maxHeight = 32, icon, editorRef, placeholder, noStyle } = props;
22703
22539
  useDependency(IEditorService);
22704
22540
  const commandService = useDependency(ICommandService);
22705
22541
  const univerInstanceService = useDependency(IUniverInstanceService);
@@ -22707,29 +22543,24 @@ const RichTextEditor = (props) => {
22707
22543
  const onClickOutside = useEvent(_onClickOutside);
22708
22544
  const [height, setHeight] = useState(defaultHeight);
22709
22545
  const formulaEditorContainerRef = useRef(null);
22710
- const editorId = useMemo(() => propsEditorId !== null && propsEditorId !== void 0 ? propsEditorId : createInternalEditorID(`RICH_TEXT_EDITOR-${generateRandomId(4)}`), [propsEditorId]);
22546
+ const editorId = useMemo(() => propsEditorId ?? createInternalEditorID(`RICH_TEXT_EDITOR-${generateRandomId(4)}`), [propsEditorId]);
22711
22547
  const editor = useEditor({
22712
22548
  editorId,
22713
22549
  initialValue,
22714
22550
  container: formulaEditorContainerRef,
22551
+ preserveHostFocus,
22715
22552
  autoFocus,
22716
22553
  isSingle
22717
22554
  });
22718
22555
  const renderer = useDependency(IRenderManagerService).getRenderUnitById(editorId);
22719
22556
  const selectionIsFocusing = useIsFocusing(editorId);
22720
22557
  const docSelectionRenderService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocSelectionRenderService);
22721
- const editorFocused = useObservable(editor ? () => {
22722
- var _docSelectionRenderSe2;
22723
- return merge$1(editor.focus$, editor.blur$).pipe(map(() => {
22724
- var _docSelectionRenderSe;
22725
- return (_docSelectionRenderSe = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing) !== null && _docSelectionRenderSe !== void 0 ? _docSelectionRenderSe : false;
22726
- }), startWith((_docSelectionRenderSe2 = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing) !== null && _docSelectionRenderSe2 !== void 0 ? _docSelectionRenderSe2 : false));
22727
- } : null, (_docSelectionRenderSe3 = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing) !== null && _docSelectionRenderSe3 !== void 0 ? _docSelectionRenderSe3 : false, false, [docSelectionRenderService, editor]);
22558
+ const editorFocused = useObservable(editor ? () => merge$1(editor.focus$, editor.blur$).pipe(map(() => (docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing) ?? false), startWith((docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing) ?? false)) : null, (docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing) ?? false, false, [docSelectionRenderService, editor]);
22728
22559
  const isFocusing = selectionIsFocusing && editorFocused;
22729
22560
  const sheetEmbeddingRef = useRef(null);
22730
22561
  const resolveShowPlaceholder = () => {
22731
- var _editor$getDocumentDa, _editor$getDocumentDa2;
22732
- return !BuildTextUtils.transform.getPlainText((_editor$getDocumentDa = editor === null || editor === void 0 || (_editor$getDocumentDa2 = editor.getDocumentData().body) === null || _editor$getDocumentDa2 === void 0 ? void 0 : _editor$getDocumentDa2.dataStream) !== null && _editor$getDocumentDa !== void 0 ? _editor$getDocumentDa : "");
22562
+ var _editor$getDocumentDa;
22563
+ return !BuildTextUtils.transform.getPlainText((editor === null || editor === void 0 || (_editor$getDocumentDa = editor.getDocumentData().body) === null || _editor$getDocumentDa === void 0 ? void 0 : _editor$getDocumentDa.dataStream) ?? "");
22733
22564
  };
22734
22565
  const showPlaceholder = useObservable(editor ? () => editor.selectionChange$.pipe(map(resolveShowPlaceholder), startWith(resolveShowPlaceholder())) : null, resolveShowPlaceholder(), false, [editor]);
22735
22566
  const { checkScrollBar } = useResize(editor, isSingle, true, true);
@@ -22742,20 +22573,20 @@ const RichTextEditor = (props) => {
22742
22573
  editorRef.current = editor;
22743
22574
  }, [editor]);
22744
22575
  const onChange = useEvent((data) => {
22745
- var _data$body$dataStream, _data$body;
22576
+ var _data$body;
22746
22577
  const docSkeleton = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocSkeletonManagerService);
22747
22578
  const size = docSkeleton === null || docSkeleton === void 0 ? void 0 : docSkeleton.getSkeleton().getActualSize();
22748
22579
  if (size) {
22749
22580
  onHeightChange === null || onHeightChange === void 0 || onHeightChange(size.actualHeight);
22750
22581
  setHeight(Math.max(defaultHeight, Math.min(size.actualHeight + 10, maxHeight)));
22751
22582
  }
22752
- _onChange === null || _onChange === void 0 || _onChange(data, getPlainText((_data$body$dataStream = (_data$body = data.body) === null || _data$body === void 0 ? void 0 : _data$body.dataStream) !== null && _data$body$dataStream !== void 0 ? _data$body$dataStream : ""));
22583
+ _onChange === null || _onChange === void 0 || _onChange(data, getPlainText(((_data$body = data.body) === null || _data$body === void 0 ? void 0 : _data$body.dataStream) ?? ""));
22753
22584
  checkScrollBar();
22754
22585
  });
22755
22586
  useEffect(() => {
22756
- var _data$body$dataStream2, _data$body2;
22587
+ var _data$body2;
22757
22588
  const data = editor === null || editor === void 0 ? void 0 : editor.getDocumentData();
22758
- onFocusChange === null || onFocusChange === void 0 || onFocusChange(isFocusing, getPlainText((_data$body$dataStream2 = data === null || data === void 0 || (_data$body2 = data.body) === null || _data$body2 === void 0 ? void 0 : _data$body2.dataStream) !== null && _data$body$dataStream2 !== void 0 ? _data$body$dataStream2 : ""));
22589
+ onFocusChange === null || onFocusChange === void 0 || onFocusChange(isFocusing, getPlainText((data === null || data === void 0 || (_data$body2 = data.body) === null || _data$body2 === void 0 ? void 0 : _data$body2.dataStream) ?? ""));
22759
22590
  }, [isFocusing, onFocusChange]);
22760
22591
  useEditorClickOutside(editorId, sheetEmbeddingRef, onClickOutside);
22761
22592
  const resolvedKeyboardEventConfig = useMemo(() => createEditorUndoRedoKeyboardConfig({