@univerjs/docs-ui 1.0.0-alpha.6 → 1.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -151,6 +151,11 @@ function deleteCustomDecorationFactory(accessor, params) {
151
151
 
152
152
  //#endregion
153
153
  //#region src/basics/paragraph.ts
154
+ function isTopLevelStructuralGap(dataStream, offset) {
155
+ const previousToken = dataStream[offset - 1];
156
+ const nextToken = dataStream[offset];
157
+ return previousToken === _univerjs_core.DataStreamTreeTokenType.BLOCK_END || previousToken === _univerjs_core.DataStreamTreeTokenType.TABLE_END || previousToken === _univerjs_core.DataStreamTreeTokenType.COLUMN_GROUP_END || nextToken === _univerjs_core.DataStreamTreeTokenType.BLOCK_START || nextToken === _univerjs_core.DataStreamTreeTokenType.TABLE_START || nextToken === _univerjs_core.DataStreamTreeTokenType.COLUMN_GROUP_START;
158
+ }
154
159
  function hasParagraphInTable(paragraph, tables) {
155
160
  return tables.some((table) => paragraph.startIndex > table.startIndex && paragraph.startIndex < table.endIndex);
156
161
  }
@@ -524,11 +529,6 @@ const BreakLineCommand = {
524
529
  return Boolean(result);
525
530
  }
526
531
  };
527
- function isTopLevelStructuralGap(dataStream, offset) {
528
- const previousToken = dataStream[offset - 1];
529
- const nextToken = dataStream[offset];
530
- return previousToken === _univerjs_core.DataStreamTreeTokenType.BLOCK_END || previousToken === _univerjs_core.DataStreamTreeTokenType.TABLE_END || previousToken === _univerjs_core.DataStreamTreeTokenType.COLUMN_GROUP_END || nextToken === _univerjs_core.DataStreamTreeTokenType.BLOCK_START || nextToken === _univerjs_core.DataStreamTreeTokenType.TABLE_START || nextToken === _univerjs_core.DataStreamTreeTokenType.COLUMN_GROUP_START;
531
- }
532
532
 
533
533
  //#endregion
534
534
  //#region src/services/clipboard/doc-paste-mutation-adapter.service.ts
@@ -1082,7 +1082,7 @@ const InnerPasteCommand = {
1082
1082
  id: "doc.command.inner-paste",
1083
1083
  type: _univerjs_core.CommandType.COMMAND,
1084
1084
  handler: async (accessor, params) => {
1085
- var _docDataModel$getSelf, _body$tables, _body$customBlocks;
1085
+ var _docDataModel$getSelf, _body$tables, _body$customBlocks, _body$blockRanges;
1086
1086
  const { segmentId, textRanges, doc } = params;
1087
1087
  const commandService = accessor.get(_univerjs_core.ICommandService);
1088
1088
  const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
@@ -1116,6 +1116,7 @@ const InnerPasteCommand = {
1116
1116
  const resourceMutationGroups = [];
1117
1117
  const hasTable = !!((_body$tables = body.tables) === null || _body$tables === void 0 ? void 0 : _body$tables.length);
1118
1118
  const hasCustomBlock = !!((_body$customBlocks = body.customBlocks) === null || _body$customBlocks === void 0 ? void 0 : _body$customBlocks.length);
1119
+ const hasBlockRange = !!((_body$blockRanges = body.blockRanges) === null || _body$blockRanges === void 0 ? void 0 : _body$blockRanges.length);
1119
1120
  if (hasTable && segmentId) return false;
1120
1121
  if (hasTable && hasRangeInTable(selections)) return false;
1121
1122
  if (selections.length && (rectRanges === null || rectRanges === void 0 ? void 0 : rectRanges.length)) return false;
@@ -1125,6 +1126,16 @@ const InnerPasteCommand = {
1125
1126
  const { startOffset, endOffset, collapsed } = selection;
1126
1127
  const len = startOffset - memoryCursor.cursor;
1127
1128
  const cloneBody = _univerjs_core.Tools.deepClone(body);
1129
+ const blockRangeMappings = [];
1130
+ const customBlockMappings = [];
1131
+ if (hasBlockRange) cloneBody.blockRanges.forEach((targetBlockRange, index) => {
1132
+ const sourceBlockRange = body.blockRanges[index];
1133
+ targetBlockRange.blockId = (0, _univerjs_core.generateRandomId)(6);
1134
+ blockRangeMappings.push({
1135
+ sourceBlockRange,
1136
+ targetBlockRange
1137
+ });
1138
+ });
1128
1139
  if (hasTable) for (const t of cloneBody.tables) {
1129
1140
  const { tableId: oldTableId } = t;
1130
1141
  const tableId = (0, _univerjs_core.generateRandomId)(6);
@@ -1137,7 +1148,6 @@ const InnerPasteCommand = {
1137
1148
  if (hasCustomBlock && drawings) {
1138
1149
  var _docDataModel$getSnap, _docDataModel$getSnap2;
1139
1150
  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;
1140
- const customBlockMappings = [];
1141
1151
  for (const block of cloneBody.customBlocks) {
1142
1152
  const { blockId } = block;
1143
1153
  const drawingId = (0, _univerjs_core.generateRandomId)(6);
@@ -1152,21 +1162,6 @@ const InnerPasteCommand = {
1152
1162
  targetDrawing: drawing
1153
1163
  });
1154
1164
  }
1155
- if (customBlockMappings.length > 0 && pasteAdapterService) {
1156
- const mutationInfos = pasteAdapterService.getPasteMutationInfos({
1157
- unitId,
1158
- segmentId,
1159
- doc,
1160
- sourceBody: body,
1161
- targetBody: cloneBody,
1162
- customBlockMappings
1163
- });
1164
- if (mutationInfos.redoMutations.length > 0 || mutationInfos.undoMutations.length > 0) {
1165
- resourceRedoMutations.push(...mutationInfos.redoMutations);
1166
- resourceUndoMutations.push(...mutationInfos.undoMutations);
1167
- resourceMutationGroups.push(mutationInfos);
1168
- }
1169
- }
1170
1165
  customBlockMappings.forEach(({ targetBlockId, targetDrawing }) => {
1171
1166
  const action = jsonX.insertOp(["drawings", targetBlockId], targetDrawing);
1172
1167
  const orderAction = jsonX.insertOp(["drawingsOrder", drawingLen], targetBlockId);
@@ -1174,6 +1169,22 @@ const InnerPasteCommand = {
1174
1169
  rawActions.push(orderAction);
1175
1170
  });
1176
1171
  }
1172
+ if ((blockRangeMappings.length > 0 || customBlockMappings.length > 0) && pasteAdapterService) {
1173
+ const mutationInfos = pasteAdapterService.getPasteMutationInfos({
1174
+ unitId,
1175
+ segmentId,
1176
+ doc,
1177
+ sourceBody: body,
1178
+ targetBody: cloneBody,
1179
+ blockRangeMappings,
1180
+ customBlockMappings
1181
+ });
1182
+ if (mutationInfos.redoMutations.length > 0 || mutationInfos.undoMutations.length > 0) {
1183
+ resourceRedoMutations.push(...mutationInfos.redoMutations);
1184
+ resourceUndoMutations.push(...mutationInfos.undoMutations);
1185
+ resourceMutationGroups.push(mutationInfos);
1186
+ }
1187
+ }
1177
1188
  const customRange = getCustomRangeAtPosition((_originBody$customRan = originBody.customRanges) !== null && _originBody$customRan !== void 0 ? _originBody$customRan : [], endOffset, UNITS.includes(unitId));
1178
1189
  const customDecorations = getCustomDecorationAtPosition((_originBody$customDec = originBody.customDecorations) !== null && _originBody$customDec !== void 0 ? _originBody$customDec : [], endOffset);
1179
1190
  if (customRange) cloneBody.customRanges = [{
@@ -3729,6 +3740,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
3729
3740
  this._clipboardInterfaceService = _clipboardInterfaceService;
3730
3741
  this._docSelectionManagerService = _docSelectionManagerService;
3731
3742
  _defineProperty(this, "_clipboardHooks", []);
3743
+ _defineProperty(this, "_memoryClipboardData", null);
3732
3744
  _defineProperty(this, "_htmlToUDM", new HtmlToUDMService());
3733
3745
  _defineProperty(this, "_umdToHtml", void 0);
3734
3746
  this._umdToHtml = new UDMToHtmlService(docHtmlExportService);
@@ -3740,7 +3752,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
3740
3752
  try {
3741
3753
  var _allRanges$;
3742
3754
  const isCopyInHeaderFooter = !!(allRanges === null || allRanges === void 0 || (_allRanges$ = allRanges[0]) === null || _allRanges$ === void 0 ? void 0 : _allRanges$.segmentId);
3743
- this._setClipboardData(newSnapshotList, !isCopyInHeaderFooter && needCache);
3755
+ await this._setClipboardData(newSnapshotList, !isCopyInHeaderFooter && needCache);
3744
3756
  } catch (e) {
3745
3757
  this._logService.error("[DocClipboardService] copy failed", e);
3746
3758
  return false;
@@ -3751,6 +3763,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
3751
3763
  return this._cut(ranges);
3752
3764
  }
3753
3765
  async paste(items) {
3766
+ if (!(items === null || items === void 0 ? void 0 : items.length)) return this._memoryClipboardData ? this._paste(_univerjs_core.Tools.deepClone(this._memoryClipboardData)) : false;
3754
3767
  const partDocData = await this._genDocDataFromClipboardItems(items);
3755
3768
  return this._paste(partDocData);
3756
3769
  }
@@ -3808,11 +3821,12 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
3808
3821
  }
3809
3822
  }
3810
3823
  async _paste(docData) {
3811
- var _this$_univerInstance, _body$customRanges, _body$paragraphs;
3824
+ var _body$customRanges, _body$paragraphs, _currentDocument$getS;
3812
3825
  const { body: _body } = docData;
3813
3826
  if (_body == null) return false;
3814
3827
  let body = (0, _univerjs_core.normalizeBody)(_body);
3815
- if (!((_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId())) return false;
3828
+ const currentDocument = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
3829
+ if (!currentDocument) return false;
3816
3830
  this._clipboardHooks.forEach((hook) => {
3817
3831
  if (hook.onBeforePaste) body = hook.onBeforePaste(body);
3818
3832
  });
@@ -3825,6 +3839,8 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
3825
3839
  const ranges = this._docSelectionManagerService.getTextRanges();
3826
3840
  if (segmentId == null) this._logService.error("[DocClipboardController] segmentId does not exist!");
3827
3841
  if (activeEndOffset == null || ranges == null) return false;
3842
+ const originBody = segmentId == null ? null : (_currentDocument$getS = currentDocument.getSelfOrHeaderFooterModel(segmentId)) === null || _currentDocument$getS === void 0 ? void 0 : _currentDocument$getS.getBody();
3843
+ if (originBody) ensureParagraphAtStructuralGap(body, originBody, ranges);
3828
3844
  try {
3829
3845
  let cursor = activeEndOffset;
3830
3846
  for (const range of ranges) {
@@ -3873,7 +3889,8 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
3873
3889
  html = embedInternalClipboardFragment(html, internalJson);
3874
3890
  }
3875
3891
  html = wrapClipboardHtml(html);
3876
- return this._clipboardInterfaceService.write(text, html, internalJson ? { [DOC_INTERNAL_FRAGMENT_MIME]: internalJson } : void 0);
3892
+ await this._clipboardInterfaceService.write(text, html, internalJson ? { [DOC_INTERNAL_FRAGMENT_MIME]: internalJson } : void 0);
3893
+ this._memoryClipboardData = _univerjs_core.Tools.deepClone(internalDocData);
3877
3894
  }
3878
3895
  addClipboardHook(hook) {
3879
3896
  this._clipboardHooks.push(hook);
@@ -4098,6 +4115,21 @@ DocClipboardService = __decorate([
4098
4115
  __decorateParam(4, (0, _univerjs_core.Inject)(DocHtmlExportService)),
4099
4116
  __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService))
4100
4117
  ], DocClipboardService);
4118
+ function endsAtDocumentBoundary(dataStream) {
4119
+ const lastToken = dataStream[dataStream.length - 1];
4120
+ return lastToken === _univerjs_core.DataStreamTreeTokenType.PARAGRAPH || lastToken === _univerjs_core.DataStreamTreeTokenType.SECTION_BREAK || lastToken === _univerjs_core.DataStreamTreeTokenType.BLOCK_END || lastToken === _univerjs_core.DataStreamTreeTokenType.TABLE_END || lastToken === _univerjs_core.DataStreamTreeTokenType.COLUMN_GROUP_END;
4121
+ }
4122
+ function ensureParagraphAtStructuralGap(body, originBody, ranges) {
4123
+ var _body$paragraphs$map, _body$paragraphs2, _body$paragraphs3;
4124
+ if (endsAtDocumentBoundary(body.dataStream) || !ranges.every((range) => range.collapsed && isTopLevelStructuralGap(originBody.dataStream, range.startOffset))) return;
4125
+ const paragraphIndex = body.dataStream.length;
4126
+ 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 : []);
4127
+ body.dataStream += _univerjs_core.DataStreamTreeTokenType.PARAGRAPH;
4128
+ body.paragraphs = [...(_body$paragraphs3 = body.paragraphs) !== null && _body$paragraphs3 !== void 0 ? _body$paragraphs3 : [], {
4129
+ startIndex: paragraphIndex,
4130
+ paragraphId: (0, _univerjs_core.createParagraphId)(paragraphIds)
4131
+ }];
4132
+ }
4101
4133
  function dataUrlToFile(dataUrl, fallbackName) {
4102
4134
  const match = /^data:([^;,]+)(;base64)?,(.*)$/i.exec(dataUrl);
4103
4135
  if (!match) throw new Error("[DocClipboardService] invalid image data url.");
@@ -4173,8 +4205,8 @@ const DocPasteCommand = {
4173
4205
  preconditions: whenDocOrEditor,
4174
4206
  handler: async (accessor) => {
4175
4207
  const docClipboardService = accessor.get(IDocClipboardService);
4176
- const clipboardItems = await accessor.get(_univerjs_ui.IClipboardInterfaceService).read();
4177
- if (clipboardItems.length === 0) return false;
4208
+ const clipboardInterfaceService = accessor.get(_univerjs_ui.IClipboardInterfaceService);
4209
+ const clipboardItems = clipboardInterfaceService.supportClipboard ? await clipboardInterfaceService.read() : [];
4178
4210
  return docClipboardService.paste(clipboardItems);
4179
4211
  }
4180
4212
  };
@@ -6416,7 +6448,7 @@ var NodePositionConvertToCursor = class {
6416
6448
  const rawAnchorGlyph = isStartBack ? preGlyph !== null && preGlyph !== void 0 ? preGlyph : firstGlyph : firstGlyph;
6417
6449
  const anchorGlyph = this._getCaretGlyph(rawAnchorGlyph, glyphGroup, start_sp);
6418
6450
  const selectedGlyphs = glyphGroup.slice(start_sp, end_sp + 1);
6419
- const isSelectionOnlyNonInlineEmbedBlock = !collapsed && selectedGlyphs.length > 0 && selectedGlyphs.every((glyph) => this._isNonInlineEmbedCustomBlockGlyph(glyph));
6451
+ const isSelectionOnlyNonInlineDrawing = !collapsed && selectedGlyphs.length > 0 && selectedGlyphs.every((glyph) => this._isNonInlineDrawingGlyph(glyph));
6420
6452
  const borderBoxStartY = startY;
6421
6453
  const borderBoxEndY = contentHeight == null ? startY + lineHeight - marginTop - marginBottom : startY + paddingTop + contentHeight + paddingBottom;
6422
6454
  if (start_sp === 0 && end_sp === glyphGroup.length - 1) {
@@ -6449,8 +6481,8 @@ var NodePositionConvertToCursor = class {
6449
6481
  }
6450
6482
  const clippedBorderBoxPosition = clipPositionToHorizontalRange(borderBoxPosition, this._horizontalClip);
6451
6483
  const clippedContentBoxPosition = clipPositionToHorizontalRange(contentBoxPosition, this._horizontalClip);
6452
- if (clippedBorderBoxPosition && !isSelectionOnlyNonInlineEmbedBlock) borderBoxPointGroup.push(pushToPoints(clippedBorderBoxPosition));
6453
- if (clippedContentBoxPosition && !isSelectionOnlyNonInlineEmbedBlock) contentBoxPointGroup.push(pushToPoints(clippedContentBoxPosition));
6484
+ if (clippedBorderBoxPosition && !isSelectionOnlyNonInlineDrawing) borderBoxPointGroup.push(pushToPoints(clippedBorderBoxPosition));
6485
+ if (clippedContentBoxPosition && !isSelectionOnlyNonInlineDrawing) contentBoxPointGroup.push(pushToPoints(clippedContentBoxPosition));
6454
6486
  cursorList.push({
6455
6487
  startOffset: isStartBack ? startOffset : startOffset + firstGlyph.count,
6456
6488
  endOffset: isEndBack ? endOffset : endOffset + lastGlyph.count,
@@ -6465,7 +6497,7 @@ var NodePositionConvertToCursor = class {
6465
6497
  }
6466
6498
  _getCaretGlyph(glyph, glyphGroup, glyphIndex) {
6467
6499
  var _this$_findTextLikeGl;
6468
- if (!glyph || !this._isNonInlineEmbedCustomBlockGlyph(glyph)) return glyph;
6500
+ if (!glyph || !this._isNonInlineDrawingGlyph(glyph)) return glyph;
6469
6501
  const neighbor = (_this$_findTextLikeGl = this._findTextLikeGlyph(glyphGroup, glyphIndex - 1, -1)) !== null && _this$_findTextLikeGl !== void 0 ? _this$_findTextLikeGl : this._findTextLikeGlyph(glyphGroup, glyphIndex + 1, 1);
6470
6502
  return neighbor !== null && neighbor !== void 0 ? neighbor : {
6471
6503
  ...glyph,
@@ -6475,13 +6507,14 @@ var NodePositionConvertToCursor = class {
6475
6507
  _findTextLikeGlyph(glyphGroup, startIndex, step) {
6476
6508
  for (let index = startIndex; index >= 0 && index < glyphGroup.length; index += step) {
6477
6509
  const glyph = glyphGroup[index];
6478
- if (!this._isNonInlineEmbedCustomBlockGlyph(glyph)) return glyph;
6510
+ if (!this._isNonInlineDrawingGlyph(glyph)) return glyph;
6479
6511
  }
6480
6512
  }
6481
- _isNonInlineEmbedCustomBlockGlyph(glyph) {
6513
+ _isNonInlineDrawingGlyph(glyph) {
6482
6514
  var _this$_docSkeleton$ge, _this$_docSkeleton, _this$_docSkeleton$ge2, _this$_docSkeleton$ge3, _this$_docSkeleton$ge4, _this$_docSkeleton$ge5;
6483
6515
  if (!(glyph === null || glyph === void 0 ? void 0 : glyph.drawingId) || glyph.streamType !== _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK) return false;
6484
- return !(0, _univerjs_docs.shouldUseInlineTextSelectionForDocsCustomBlockDrawing)((_this$_docSkeleton$ge = (_this$_docSkeleton = this._docSkeleton).getViewModel) === null || _this$_docSkeleton$ge === void 0 || (_this$_docSkeleton$ge3 = (_this$_docSkeleton$ge2 = _this$_docSkeleton$ge.call(_this$_docSkeleton)).getDataModel) === null || _this$_docSkeleton$ge3 === void 0 || (_this$_docSkeleton$ge5 = (_this$_docSkeleton$ge4 = _this$_docSkeleton$ge3.call(_this$_docSkeleton$ge2)).getSnapshot) === null || _this$_docSkeleton$ge5 === void 0 || (_this$_docSkeleton$ge5 = _this$_docSkeleton$ge5.call(_this$_docSkeleton$ge4).drawings) === null || _this$_docSkeleton$ge5 === void 0 ? void 0 : _this$_docSkeleton$ge5[glyph.drawingId]);
6516
+ const drawing = (_this$_docSkeleton$ge = (_this$_docSkeleton = this._docSkeleton).getViewModel) === null || _this$_docSkeleton$ge === void 0 || (_this$_docSkeleton$ge3 = (_this$_docSkeleton$ge2 = _this$_docSkeleton$ge.call(_this$_docSkeleton)).getDataModel) === null || _this$_docSkeleton$ge3 === void 0 || (_this$_docSkeleton$ge5 = (_this$_docSkeleton$ge4 = _this$_docSkeleton$ge3.call(_this$_docSkeleton$ge2)).getSnapshot) === null || _this$_docSkeleton$ge5 === void 0 || (_this$_docSkeleton$ge5 = _this$_docSkeleton$ge5.call(_this$_docSkeleton$ge4).drawings) === null || _this$_docSkeleton$ge5 === void 0 ? void 0 : _this$_docSkeleton$ge5[glyph.drawingId];
6517
+ return (drawing === null || drawing === void 0 ? void 0 : drawing.layoutType) == null ? !(0, _univerjs_docs.shouldUseInlineTextSelectionForDocsCustomBlockDrawing)(drawing) : drawing.layoutType !== _univerjs_core.PositionedObjectLayoutType.INLINE;
6485
6518
  }
6486
6519
  _isValidPosition(startOrigin, endOrigin) {
6487
6520
  const { segmentPage: startPage, pageType: startPageType } = startOrigin;
@@ -8182,8 +8215,16 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
8182
8215
  sync() {
8183
8216
  this._updateInputPosition();
8184
8217
  }
8218
+ setInputPosition(x, y) {
8219
+ this._positionInput(x, y);
8220
+ }
8185
8221
  activate(x, y, force = false) {
8222
+ this._positionInput(x, y);
8223
+ if (force && !this._shouldPreserveExternalFocus() || !force && this.canFocusing) this.focus();
8224
+ }
8225
+ _positionInput(x, y) {
8186
8226
  this._ensureHostContainer();
8227
+ this._container.style.position = "fixed";
8187
8228
  let left = x;
8188
8229
  let top = y;
8189
8230
  const fixedContainer = this._container.offsetParent;
@@ -8195,7 +8236,6 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
8195
8236
  this._container.style.left = `${left}px`;
8196
8237
  this._container.style.top = `${top}px`;
8197
8238
  this._container.style.zIndex = "1000";
8198
- if (force && !this._shouldPreserveExternalFocus() || !force && this.canFocusing) this.focus();
8199
8239
  }
8200
8240
  hasFocus() {
8201
8241
  return this._getOwnerDocument().activeElement === this._input;
@@ -9240,13 +9280,14 @@ const DocTableDeleteColumnsCommand = {
9240
9280
  const DocTableDeleteTableCommand = {
9241
9281
  id: "doc.table.delete-table",
9242
9282
  type: _univerjs_core.CommandType.COMMAND,
9243
- handler: async (accessor) => {
9244
- var _docDataModel$getSelf3;
9283
+ handler: async (accessor, params) => {
9284
+ var _params$targetRange, _docDataModel$getSelf3;
9245
9285
  const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
9246
9286
  const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
9247
9287
  const commandService = accessor.get(_univerjs_core.ICommandService);
9248
9288
  const activeRectRanges = docSelectionManagerService.getRectRanges();
9249
- const rangeInfo = getRangeInfoFromRanges(docSelectionManagerService.getActiveTextRange(), activeRectRanges);
9289
+ const activeTextRange = docSelectionManagerService.getActiveTextRange();
9290
+ 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);
9250
9291
  if (rangeInfo == null) return false;
9251
9292
  const { segmentId } = rangeInfo;
9252
9293
  const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
@@ -10709,10 +10750,7 @@ function getPageSizeInModernMode(page) {
10709
10750
  const { marginLeft, marginRight, marginTop, marginBottom, skeDrawings, skeTables } = page;
10710
10751
  if (pageWidth === Number.POSITIVE_INFINITY) pageWidth = page.width + marginLeft + marginRight;
10711
10752
  if (pageHeight === Number.POSITIVE_INFINITY) pageHeight = page.height + marginTop + marginBottom;
10712
- for (const drawing of skeDrawings.values()) {
10713
- pageWidth = Math.max(pageWidth, drawing.aLeft + drawing.width + marginLeft + marginRight);
10714
- pageHeight = Math.max(pageHeight, drawing.aTop + drawing.height + marginTop + marginBottom);
10715
- }
10753
+ for (const drawing of skeDrawings.values()) pageHeight = Math.max(pageHeight, drawing.aTop + drawing.height + marginTop + marginBottom);
10716
10754
  for (const table of skeTables.values()) pageHeight = Math.max(pageHeight, table.top + table.height + marginTop + marginBottom);
10717
10755
  return {
10718
10756
  pageWidth,
@@ -11095,7 +11133,7 @@ function PageSettings(props) {
11095
11133
  className: "univer-grid univer-grid-cols-3 univer-gap-2",
11096
11134
  children: MODERN_WIDTH_OPTIONS.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
11097
11135
  type: "button",
11098
- className: (0, _univerjs_design.clsx)("univer-flex univer-h-16 univer-cursor-pointer univer-flex-col univer-items-center univer-justify-center univer-gap-1 univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-text-sm univer-font-medium univer-text-gray-700 univer-transition-colors hover:univer-border-primary-500 hover:univer-text-primary-600 dark:!univer-border-gray-600 dark:!univer-bg-gray-900 dark:!univer-text-gray-100", { "!univer-border-primary-500 !univer-bg-primary-50 !univer-text-primary-600 dark:!univer-bg-primary-900": settings.modernWidth === option }),
11136
+ className: (0, _univerjs_design.clsx)(_univerjs_design.resetButtonClassName, _univerjs_design.borderClassName, "univer-h-16 univer-flex-col univer-gap-1 univer-rounded-lg univer-bg-white univer-text-sm univer-font-medium univer-text-gray-700 univer-transition-colors hover:univer-border-primary-500 hover:univer-text-primary-600 dark:!univer-bg-gray-900 dark:!univer-text-gray-100", { "!univer-border-primary-500 !univer-bg-primary-50 !univer-text-primary-600 dark:!univer-bg-primary-900": settings.modernWidth === option }),
11099
11137
  onClick: () => handleModernWidthChange(option),
11100
11138
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t(`docs-ui.page-settings.modern-width-${option}`) }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
11101
11139
  className: "univer-text-xs univer-font-normal univer-text-gray-400",
@@ -11586,6 +11624,54 @@ function DeleteTableMenuItemFactory(accessor) {
11586
11624
  };
11587
11625
  }
11588
11626
 
11627
+ //#endregion
11628
+ //#region src/commands/commands/insert-special-character.command.ts
11629
+ const InsertSpecialCharacterCommand = {
11630
+ id: "doc.command.insert-special-character",
11631
+ type: _univerjs_core.CommandType.COMMAND,
11632
+ handler: (accessor, params) => {
11633
+ var _docDataModel$getSelf, _originBody$customRan, _originBody$customDec;
11634
+ if (!(params === null || params === void 0 ? void 0 : params.value)) return false;
11635
+ const commandService = accessor.get(_univerjs_core.ICommandService);
11636
+ const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
11637
+ const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
11638
+ const docMenuStyleService = accessor.get(DocMenuStyleService);
11639
+ const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
11640
+ const activeRange = docSelectionManagerService.getActiveTextRange();
11641
+ if (!docDataModel || !activeRange) return false;
11642
+ const { segmentId } = activeRange;
11643
+ const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
11644
+ if (!originBody) return false;
11645
+ const { value } = params;
11646
+ const curTextRun = getTextRunAtPosition(originBody, activeRange.endOffset, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache());
11647
+ const curCustomRange = getCustomRangeAtPosition((_originBody$customRan = originBody.customRanges) !== null && _originBody$customRan !== void 0 ? _originBody$customRan : [], activeRange.endOffset);
11648
+ const curCustomDecorations = getCustomDecorationAtPosition((_originBody$customDec = originBody.customDecorations) !== null && _originBody$customDec !== void 0 ? _originBody$customDec : [], activeRange.endOffset);
11649
+ return commandService.executeCommand(_univerjs_docs.InsertTextCommand.id, {
11650
+ unitId: docDataModel.getUnitId(),
11651
+ body: {
11652
+ dataStream: value,
11653
+ textRuns: [{
11654
+ ...curTextRun,
11655
+ st: 0,
11656
+ ed: value.length
11657
+ }],
11658
+ customRanges: curCustomRange ? [{
11659
+ ...curCustomRange,
11660
+ startIndex: 0,
11661
+ endIndex: value.length - 1
11662
+ }] : [],
11663
+ customDecorations: curCustomDecorations.map((customDecoration) => ({
11664
+ ...customDecoration,
11665
+ startIndex: 0,
11666
+ endIndex: value.length - 1
11667
+ }))
11668
+ },
11669
+ range: activeRange,
11670
+ segmentId
11671
+ });
11672
+ }
11673
+ };
11674
+
11589
11675
  //#endregion
11590
11676
  //#region src/views/const.ts
11591
11677
  /**
@@ -11750,16 +11836,22 @@ function getInsertTableHiddenObservable(accessor) {
11750
11836
  const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
11751
11837
  const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
11752
11838
  return new rxjs.Observable((subscriber) => {
11839
+ let editAreaSubscription = null;
11753
11840
  const subscription = univerInstanceService.focused$.subscribe((unitId) => {
11841
+ editAreaSubscription === null || editAreaSubscription === void 0 || editAreaSubscription.unsubscribe();
11842
+ editAreaSubscription = null;
11754
11843
  if (unitId == null) return subscriber.next(true);
11755
11844
  if (univerInstanceService.getUnitType(unitId) !== _univerjs_core.UniverInstanceType.UNIVER_DOC) return subscriber.next(true);
11756
11845
  const currentRender = renderManagerService.getRenderById(unitId);
11757
11846
  if (currentRender == null) return subscriber.next(true);
11758
- currentRender.with(_univerjs_docs.DocSkeletonManagerService).getViewModel().editAreaChange$.subscribe((editArea) => {
11847
+ editAreaSubscription = currentRender.with(_univerjs_docs.DocSkeletonManagerService).getViewModel().editAreaChange$.subscribe((editArea) => {
11759
11848
  subscriber.next(editArea === _univerjs_engine_render.DocumentEditArea.HEADER || editArea === _univerjs_engine_render.DocumentEditArea.FOOTER);
11760
11849
  });
11761
11850
  });
11762
- return () => subscription.unsubscribe();
11851
+ return () => {
11852
+ editAreaSubscription === null || editAreaSubscription === void 0 || editAreaSubscription.unsubscribe();
11853
+ subscription.unsubscribe();
11854
+ };
11763
11855
  });
11764
11856
  }
11765
11857
  function disableMenuWhenHeaderFooterEditing(accessor) {
@@ -11825,9 +11917,8 @@ function getHeaderFooterMenuHiddenObservable(accessor) {
11825
11917
  subscriber.next(documentFlavor !== _univerjs_core.DocumentFlavor.TRADITIONAL);
11826
11918
  });
11827
11919
  const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
11828
- if (docDataModel == null) return subscriber.next(true);
11829
11920
  const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
11830
- subscriber.next(documentFlavor !== _univerjs_core.DocumentFlavor.TRADITIONAL);
11921
+ subscriber.next(docDataModel == null || documentFlavor !== _univerjs_core.DocumentFlavor.TRADITIONAL);
11831
11922
  return () => {
11832
11923
  subscription0.dispose();
11833
11924
  subscription.unsubscribe();
@@ -11904,6 +11995,42 @@ function disableMenuWhenNoDocRange(accessor) {
11904
11995
  return () => subscription.unsubscribe();
11905
11996
  });
11906
11997
  }
11998
+ const DOC_INSERT_EMOJI_MENU_ID = "doc.menu.insert-emoji";
11999
+ const DOC_INSERT_SYMBOL_MENU_ID = "doc.menu.insert-symbol";
12000
+ function EmojiPickerMenuItemFactory(accessor) {
12001
+ return {
12002
+ id: DOC_INSERT_EMOJI_MENU_ID,
12003
+ type: _univerjs_ui.MenuItemType.SELECTOR,
12004
+ icon: "SmileIcon",
12005
+ tooltip: "ui.emojiPicker.emojis",
12006
+ selectionsCommandId: InsertSpecialCharacterCommand.id,
12007
+ selections: [{ label: {
12008
+ name: _univerjs_ui.EMOJI_PICKER_COMPONENT,
12009
+ hoverable: false,
12010
+ selectable: false,
12011
+ props: { embedded: true }
12012
+ } }],
12013
+ disabled$: disableMenuWhenNoDocRange(accessor),
12014
+ hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
12015
+ };
12016
+ }
12017
+ function SymbolPickerMenuItemFactory(accessor) {
12018
+ return {
12019
+ id: DOC_INSERT_SYMBOL_MENU_ID,
12020
+ type: _univerjs_ui.MenuItemType.SELECTOR,
12021
+ icon: "SymbolsIcon",
12022
+ tooltip: "ui.emojiPicker.symbols",
12023
+ selectionsCommandId: InsertSpecialCharacterCommand.id,
12024
+ selections: [{ label: {
12025
+ name: _univerjs_ui.SYMBOL_PICKER_COMPONENT,
12026
+ hoverable: false,
12027
+ selectable: false,
12028
+ props: { embedded: true }
12029
+ } }],
12030
+ disabled$: disableMenuWhenNoDocRange(accessor),
12031
+ hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
12032
+ };
12033
+ }
11907
12034
  function isTextRangeInAnyBlockRange(document, range) {
11908
12035
  var _document$getBody$blo2, _document$getBody2;
11909
12036
  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 : [];
@@ -12564,7 +12691,10 @@ function AlignMenuItemFactory(accessor) {
12564
12691
  });
12565
12692
  calc();
12566
12693
  return disposable.dispose;
12567
- });
12694
+ }).pipe((0, rxjs.distinctUntilChanged)(), (0, rxjs.shareReplay)({
12695
+ bufferSize: 1,
12696
+ refCount: true
12697
+ }));
12568
12698
  return {
12569
12699
  id: AlignOperationCommand.id,
12570
12700
  type: _univerjs_ui.MenuItemType.SELECTOR,
@@ -13410,42 +13540,87 @@ const menuSchema = {
13410
13540
  [_univerjs_ui.RibbonStartGroup.FORMAT]: {
13411
13541
  [SetInlineFormatBoldCommand.id]: {
13412
13542
  order: 0,
13543
+ gridLayout: {
13544
+ row: 2,
13545
+ column: 1
13546
+ },
13413
13547
  menuItemFactory: BoldMenuItemFactory
13414
13548
  },
13415
13549
  [SetInlineFormatItalicCommand.id]: {
13416
13550
  order: 1,
13551
+ gridLayout: {
13552
+ row: 2,
13553
+ column: 2
13554
+ },
13417
13555
  menuItemFactory: ItalicMenuItemFactory
13418
13556
  },
13419
13557
  [SetInlineFormatUnderlineCommand.id]: {
13420
13558
  order: 2,
13559
+ gridLayout: {
13560
+ row: 2,
13561
+ column: 3
13562
+ },
13421
13563
  menuItemFactory: UnderlineMenuItemFactory
13422
13564
  },
13423
13565
  [SetInlineFormatStrikethroughCommand.id]: {
13424
13566
  order: 3,
13567
+ gridLayout: {
13568
+ row: 2,
13569
+ column: 4
13570
+ },
13425
13571
  menuItemFactory: StrikeThroughMenuItemFactory
13426
13572
  },
13427
13573
  [SetInlineFormatSubscriptCommand.id]: {
13428
13574
  order: 4,
13575
+ gridLayout: {
13576
+ row: 2,
13577
+ column: 5
13578
+ },
13429
13579
  menuItemFactory: SubscriptMenuItemFactory
13430
13580
  },
13431
13581
  [SetInlineFormatSuperscriptCommand.id]: {
13432
13582
  order: 5,
13583
+ gridLayout: {
13584
+ row: 2,
13585
+ column: 6
13586
+ },
13433
13587
  menuItemFactory: SuperscriptMenuItemFactory
13434
13588
  },
13435
13589
  [SetParagraphNamedStyleCommand.id]: {
13436
13590
  order: 5.5,
13591
+ gridLayout: {
13592
+ row: 1,
13593
+ column: 1,
13594
+ columnSpan: 2,
13595
+ width: 100
13596
+ },
13437
13597
  menuItemFactory: HeadingSelectorMenuItemFactory
13438
13598
  },
13439
13599
  [SetInlineFormatFontSizeCommand.id]: {
13440
13600
  order: 6,
13601
+ gridLayout: {
13602
+ row: 1,
13603
+ column: 7,
13604
+ width: 64
13605
+ },
13441
13606
  menuItemFactory: FontSizeSelectorMenuItemFactory
13442
13607
  },
13443
13608
  [SetInlineFormatFontFamilyCommand.id]: {
13444
13609
  order: 7,
13610
+ gridLayout: {
13611
+ row: 1,
13612
+ column: 3,
13613
+ columnSpan: 4,
13614
+ width: 160
13615
+ },
13445
13616
  menuItemFactory: FontFamilySelectorMenuItemFactory
13446
13617
  },
13447
13618
  [SetInlineFormatTextColorCommand.id]: {
13448
13619
  order: 8,
13620
+ gridLayout: {
13621
+ row: 2,
13622
+ column: 7
13623
+ },
13449
13624
  menuItemFactory: TextColorSelectorMenuItemFactory,
13450
13625
  [ResetInlineFormatTextColorCommand.id]: {
13451
13626
  order: 0,
@@ -13454,6 +13629,10 @@ const menuSchema = {
13454
13629
  },
13455
13630
  [SetInlineFormatTextBackgroundColorCommand.id]: {
13456
13631
  order: 9,
13632
+ gridLayout: {
13633
+ row: 2,
13634
+ column: 8
13635
+ },
13457
13636
  menuItemFactory: BackgroundColorSelectorMenuItemFactory,
13458
13637
  [ResetInlineFormatTextBackgroundColorCommand.id]: {
13459
13638
  order: 0,
@@ -13464,32 +13643,66 @@ const menuSchema = {
13464
13643
  [_univerjs_ui.RibbonStartGroup.LAYOUT]: {
13465
13644
  [AlignOperationCommand.id]: {
13466
13645
  order: 2,
13646
+ gridLayout: {
13647
+ row: 1,
13648
+ column: 1
13649
+ },
13467
13650
  menuItemFactory: AlignMenuItemFactory
13468
13651
  },
13469
13652
  [OrderListCommand.id]: {
13470
13653
  order: 7,
13654
+ gridLayout: {
13655
+ row: 2,
13656
+ column: 1
13657
+ },
13471
13658
  menuItemFactory: OrderListMenuItemFactory
13472
13659
  },
13473
13660
  [BulletListCommand.id]: {
13474
13661
  order: 8,
13662
+ gridLayout: {
13663
+ row: 1,
13664
+ column: 2
13665
+ },
13475
13666
  menuItemFactory: BulletListMenuItemFactory
13476
13667
  },
13477
13668
  [CheckListCommand.id]: {
13478
13669
  order: 9,
13670
+ gridLayout: {
13671
+ row: 2,
13672
+ column: 2
13673
+ },
13479
13674
  menuItemFactory: CheckListMenuItemFactory
13480
13675
  },
13481
13676
  [OpenHeaderFooterPanelCommand.id]: {
13482
13677
  order: 10,
13678
+ gridLayout: {
13679
+ row: 1,
13680
+ column: 3,
13681
+ rowSpan: 2,
13682
+ showLabel: true
13683
+ },
13483
13684
  menuItemFactory: HeaderFooterMenuItemFactory
13484
13685
  },
13485
13686
  [DocOpenPageSettingCommand.id]: {
13486
13687
  order: 12,
13688
+ gridLayout: {
13689
+ row: 1,
13690
+ column: 4,
13691
+ rowSpan: 2,
13692
+ showLabel: true
13693
+ },
13487
13694
  menuItemFactory: PageSettingMenuItemFactory
13488
13695
  }
13489
13696
  },
13490
13697
  [_univerjs_ui.RibbonInsertGroup.MEDIA]: {
13491
13698
  [TABLE_MENU_ID]: {
13492
13699
  order: 2,
13700
+ gridLayout: {
13701
+ row: 1,
13702
+ column: 1,
13703
+ rowSpan: 2,
13704
+ showLabel: true
13705
+ },
13493
13706
  menuItemFactory: TableMenuFactory,
13494
13707
  [DocCreateTableOperation.id]: {
13495
13708
  order: 0,
@@ -13498,7 +13711,29 @@ const menuSchema = {
13498
13711
  },
13499
13712
  [HorizontalLineCommand.id]: {
13500
13713
  order: 3,
13714
+ gridLayout: {
13715
+ row: 1,
13716
+ column: 2,
13717
+ rowSpan: 2,
13718
+ showLabel: true
13719
+ },
13501
13720
  menuItemFactory: HorizontalLineFactory
13721
+ },
13722
+ [DOC_INSERT_EMOJI_MENU_ID]: {
13723
+ order: 4,
13724
+ gridLayout: {
13725
+ row: 1,
13726
+ column: 3
13727
+ },
13728
+ menuItemFactory: EmojiPickerMenuItemFactory
13729
+ },
13730
+ [DOC_INSERT_SYMBOL_MENU_ID]: {
13731
+ order: 5,
13732
+ gridLayout: {
13733
+ row: 2,
13734
+ column: 3
13735
+ },
13736
+ menuItemFactory: SymbolPickerMenuItemFactory
13502
13737
  }
13503
13738
  },
13504
13739
  [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: {
@@ -13856,6 +14091,13 @@ const menuSchema = {
13856
14091
  order: 0,
13857
14092
  menuItemFactory: InsertDefaultTableMenuFactory
13858
14093
  }
14094
+ },
14095
+ format: {
14096
+ order: 3,
14097
+ [DocPasteCommand.id]: {
14098
+ order: 0,
14099
+ menuItemFactory: PasteMenuFactory
14100
+ }
13859
14101
  }
13860
14102
  },
13861
14103
  [DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID]: {
@@ -13985,8 +14227,12 @@ const menuSchema = {
13985
14227
  order: 1,
13986
14228
  menuItemFactory: CopyCurrentParagraphMenuItemFactory
13987
14229
  },
13988
- [DeleteCurrentParagraphCommand.id]: {
14230
+ [DocPasteCommand.id]: {
13989
14231
  order: 2,
14232
+ menuItemFactory: PasteMenuFactory
14233
+ },
14234
+ [DeleteCurrentParagraphCommand.id]: {
14235
+ order: 3,
13990
14236
  menuItemFactory: DeleteCurrentParagraphMenuItemFactory
13991
14237
  }
13992
14238
  },
@@ -15836,7 +16082,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
15836
16082
  //#endregion
15837
16083
  //#region package.json
15838
16084
  var name = "@univerjs/docs-ui";
15839
- var version = "1.0.0-alpha.6";
16085
+ var version = "1.0.0-alpha.7";
15840
16086
 
15841
16087
  //#endregion
15842
16088
  //#region src/commands/commands/doc-paragraph-setting.command.ts
@@ -15914,19 +16160,27 @@ const DEFAULT_AVALIABLE_MENUS = [
15914
16160
  SetInlineFormatSubscriptCommand.id,
15915
16161
  SetInlineFormatSuperscriptCommand.id,
15916
16162
  SetInlineFormatTextColorCommand.id,
15917
- SetInlineFormatTextBackgroundColorCommand.id
16163
+ {
16164
+ id: SetInlineFormatTextBackgroundColorCommand.id,
16165
+ iconColor: "var(--univer-primary-600)"
16166
+ }
15918
16167
  ];
15919
16168
  function resolveFloatToolbarMenus(menuManagerService, avaliableMenus) {
15920
16169
  const floatToolbarMenus = menuManagerService.getMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION);
15921
16170
  const flatMenus = [...menuManagerService.getFlatMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION), ...menuManagerService.getFlatMenuByPositionKey(_univerjs_ui.MenuManagerPosition.RIBBON)];
15922
16171
  const menus = [];
15923
- for (const key of avaliableMenus) {
15924
- const item = flatMenus.find((item) => item.key === key);
15925
- if (item) menus.push(item);
16172
+ const menuIds = avaliableMenus.map((config) => typeof config === "string" ? config : config.id);
16173
+ for (const config of avaliableMenus) {
16174
+ const menuId = typeof config === "string" ? config : config.id;
16175
+ const item = flatMenus.find((item) => item.key === menuId);
16176
+ if (item) menus.push(typeof config === "string" ? item : {
16177
+ ...item,
16178
+ iconColor: config.iconColor
16179
+ });
15926
16180
  }
15927
16181
  return {
15928
16182
  menus,
15929
- extraMenus: floatToolbarMenus.filter((item) => item.item && !avaliableMenus.includes(item.key))
16183
+ extraMenus: floatToolbarMenus.filter((item) => item.item && !menuIds.includes(item.key))
15930
16184
  };
15931
16185
  }
15932
16186
  function FloatToolbar(props) {
@@ -15951,7 +16205,10 @@ function FloatToolbar(props) {
15951
16205
  children: [
15952
16206
  menus.map((groupItem) => groupItem.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
15953
16207
  className: "univer-flex univer-flex-nowrap univer-gap-2 univer-px-2",
15954
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.ToolbarItem, { ...groupItem.item }, groupItem.key)
16208
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.ToolbarItem, {
16209
+ ...groupItem.item,
16210
+ iconColor: groupItem.iconColor
16211
+ }, groupItem.key)
15955
16212
  }, groupItem.key)),
15956
16213
  extraMenus.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-my-1 univer-w-px univer-bg-gray-200 dark:univer-bg-gray-700" }),
15957
16214
  extraMenus.map((groupItem) => groupItem.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -16902,14 +17159,16 @@ function isInSameLine(startNodePosition, endNodePosition) {
16902
17159
  }
16903
17160
  const SKIP_SYMBOLS = [_univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK, _univerjs_core.DataStreamTreeTokenType.PARAGRAPH];
16904
17161
  let DocFloatMenuService = class DocFloatMenuService extends _univerjs_core.Disposable {
16905
- constructor(_context, _docSelectionManagerService, _docCanvasPopManagerService, _univerInstanceService, _docSelectionRenderService) {
17162
+ constructor(_context, _docSelectionManagerService, _docCanvasPopManagerService, _univerInstanceService, _docSelectionRenderService, _contextService) {
16906
17163
  super();
16907
17164
  this._context = _context;
16908
17165
  this._docSelectionManagerService = _docSelectionManagerService;
16909
17166
  this._docCanvasPopManagerService = _docCanvasPopManagerService;
16910
17167
  this._univerInstanceService = _univerInstanceService;
16911
17168
  this._docSelectionRenderService = _docSelectionRenderService;
17169
+ this._contextService = _contextService;
16912
17170
  _defineProperty(this, "_floatMenu", null);
17171
+ _defineProperty(this, "_suppressed", false);
16913
17172
  if ((0, _univerjs_core.isInternalEditorID)(this._context.unitId)) return;
16914
17173
  this._initSelectionChange();
16915
17174
  this.disposeWithMe(() => {
@@ -16922,6 +17181,11 @@ let DocFloatMenuService = class DocFloatMenuService extends _univerjs_core.Dispo
16922
17181
  hideFloatMenu() {
16923
17182
  this._hideFloatMenu();
16924
17183
  }
17184
+ setSuppressed(suppressed) {
17185
+ if (this._suppressed === suppressed) return;
17186
+ this._suppressed = suppressed;
17187
+ if (suppressed) this._hideFloatMenu();
17188
+ }
16925
17189
  _initSelectionChange() {
16926
17190
  this.disposeWithMe(this._docSelectionRenderService.onSelectionStart$.subscribe(() => {
16927
17191
  this._hideFloatMenu();
@@ -16929,6 +17193,10 @@ let DocFloatMenuService = class DocFloatMenuService extends _univerjs_core.Dispo
16929
17193
  this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe((selection) => {
16930
17194
  const { unitId, textRanges } = selection;
16931
17195
  if (unitId !== this._context.unitId) return;
17196
+ if (this._suppressed || this._contextService.getContextValue(_univerjs_core.FOCUSING_COMMON_DRAWINGS)) {
17197
+ this._hideFloatMenu();
17198
+ return;
17199
+ }
16932
17200
  const range = textRanges.length > 0 && textRanges.find((range) => !range.collapsed);
16933
17201
  if (range) {
16934
17202
  var _this$_floatMenu, _this$_floatMenu2;
@@ -16970,7 +17238,8 @@ DocFloatMenuService = __decorate([
16970
17238
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
16971
17239
  __decorateParam(2, (0, _univerjs_core.Inject)(DocCanvasPopManagerService)),
16972
17240
  __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
16973
- __decorateParam(4, (0, _univerjs_core.Inject)(DocSelectionRenderService))
17241
+ __decorateParam(4, (0, _univerjs_core.Inject)(DocSelectionRenderService)),
17242
+ __decorateParam(5, _univerjs_core.IContextService)
16974
17243
  ], DocFloatMenuService);
16975
17244
  function isRangeInCodeBlock(documentDataModel, range) {
16976
17245
  var _documentDataModel$ge3, _documentDataModel$ge4;
@@ -17797,6 +18066,7 @@ function getParagraphMenuBlockRangeCommandId(blockType) {
17797
18066
  }
17798
18067
  const PARAGRAPH_MENU_BLOCK_RANGE_COMMAND_IDS = new Set(PARAGRAPH_MENU_BLOCK_RANGE_TYPES.map((blockType) => getParagraphMenuBlockRangeCommandId(blockType)));
17799
18068
  const PARAGRAPH_MENU_SELECTION_COMMAND_IDS = /* @__PURE__ */ new Set([
18069
+ DocPasteCommand.id,
17800
18070
  BulletListCommand.id,
17801
18071
  OrderListCommand.id,
17802
18072
  CheckListCommand.id,
@@ -17890,6 +18160,7 @@ function getParagraphMenuHiddenItemIds(menuType, target, namedStyleType) {
17890
18160
  if (menuType === "doc.menu.paragraph-t.insert") return [];
17891
18161
  const hiddenIds = [...getParagraphMenuHiddenHeadingCommandIds(namedStyleType)];
17892
18162
  const blockType = (target === null || target === void 0 ? void 0 : target.kind) === "blockRange" ? (_target$blockRange2 = target.blockRange) === null || _target$blockRange2 === void 0 ? void 0 : _target$blockRange2.blockType : void 0;
18163
+ if ((target === null || target === void 0 ? void 0 : target.kind) !== "blockRange") hiddenIds.push(DocPasteCommand.id);
17893
18164
  if (blockType === _univerjs_core.DocumentBlockRangeType.CALLOUT) hiddenIds.push(getParagraphMenuBlockRangeCommandId(_univerjs_core.DocumentBlockRangeType.CODE), getParagraphMenuBlockRangeCommandId(_univerjs_core.DocumentBlockRangeType.QUOTE));
17894
18165
  else if (blockType === _univerjs_core.DocumentBlockRangeType.QUOTE || blockType === _univerjs_core.DocumentBlockRangeType.CODE) hiddenIds.push(getParagraphMenuBlockRangeCommandId(_univerjs_core.DocumentBlockRangeType.CALLOUT));
17895
18166
  return hiddenIds;
@@ -18086,6 +18357,7 @@ function getParagraphFormattingRange(target, paragraph) {
18086
18357
  return getTargetSelectionRange(target, paragraph);
18087
18358
  }
18088
18359
  function getParagraphMenuCommandTargetRange(commandId, targetRange, formattingRange) {
18360
+ if (commandId === DocPasteCommand.id) return targetRange;
18089
18361
  if (commandId && PARAGRAPH_MENU_SELECTION_COMMAND_IDS.has(commandId)) return formattingRange !== null && formattingRange !== void 0 ? formattingRange : targetRange;
18090
18362
  return targetRange !== null && targetRange !== void 0 ? targetRange : formattingRange;
18091
18363
  }
@@ -18105,6 +18377,17 @@ function getBlockSelectionRange(target, paragraph) {
18105
18377
  segmentId: paragraph === null || paragraph === void 0 ? void 0 : paragraph.segmentId
18106
18378
  };
18107
18379
  }
18380
+ function getBlockRangeClipboardTargetRange(commandId, target, paragraph) {
18381
+ if ((target === null || target === void 0 ? void 0 : target.kind) !== "blockRange") return null;
18382
+ if (commandId === DocPasteCommand.id) return {
18383
+ startOffset: target.moveRange.endOffset,
18384
+ endOffset: target.moveRange.endOffset,
18385
+ collapsed: true,
18386
+ segmentId: paragraph === null || paragraph === void 0 ? void 0 : paragraph.segmentId
18387
+ };
18388
+ if (commandId === DocCopyCurrentParagraphCommand.id || commandId === DocCutCurrentParagraphCommand.id) return getBlockSelectionRange(target, paragraph !== null && paragraph !== void 0 ? paragraph : void 0);
18389
+ return null;
18390
+ }
18108
18391
  function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18109
18392
  var _ref3, _ref4, _currentActiveTarget$, _doc$getBody$dataStre, _doc$getBody, _currentActiveTarget$2, _paragraphObj$paragra, _currentActiveTarget$3;
18110
18393
  const [visible, setVisible] = (0, react.useState)(false);
@@ -18125,7 +18408,6 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18125
18408
  const docClipboardService = (0, _univerjs_ui.useDependency)(IDocClipboardService);
18126
18409
  const docContentInsertService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocContentInsertService);
18127
18410
  const docBlockMoveValidatorService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocBlockMoveValidatorService);
18128
- const clipboardInterfaceService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IClipboardInterfaceService);
18129
18411
  const layoutService = (0, _univerjs_ui.useDependency)(_univerjs_ui.ILayoutService);
18130
18412
  const iconManager = (0, _univerjs_ui.useDependency)(_univerjs_ui.IconManager);
18131
18413
  const anchorRef = (0, react.useRef)(null);
@@ -18320,7 +18602,19 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18320
18602
  }
18321
18603
  if ((latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.kind) === "blockRange") {
18322
18604
  var _latestTarget$blockRa;
18323
- if (commandId === getParagraphMenuBlockRangeCommandId((_latestTarget$blockRa = latestTarget.blockRange) === null || _latestTarget$blockRa === void 0 ? void 0 : _latestTarget$blockRa.blockType)) {
18605
+ const currentBlockCommandId = getParagraphMenuBlockRangeCommandId((_latestTarget$blockRa = latestTarget.blockRange) === null || _latestTarget$blockRa === void 0 ? void 0 : _latestTarget$blockRa.blockType);
18606
+ const clipboardRange = getBlockRangeClipboardTargetRange(commandId, latestTarget, activeParagraphBound);
18607
+ if (clipboardRange) {
18608
+ if (commandId === DocCopyCurrentParagraphCommand.id) await docClipboardService.copy(_univerjs_core.SliceBodyType.copy, [clipboardRange]);
18609
+ else if (commandId === DocCutCurrentParagraphCommand.id) await docClipboardService.cut([clipboardRange]);
18610
+ else {
18611
+ replaceSelection(clipboardRange);
18612
+ await executeResolvedCommand(option, clipboardRange);
18613
+ }
18614
+ finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
18615
+ return;
18616
+ }
18617
+ if (commandId === currentBlockCommandId) {
18324
18618
  await unwrapActiveBlockRange();
18325
18619
  finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
18326
18620
  return;
@@ -18569,14 +18863,16 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18569
18863
  }
18570
18864
  if (commandId === DocPasteCommand.id) {
18571
18865
  docSelectionManagerService.replaceTextRanges([afterTableRange], false);
18572
- const clipboardItems = await clipboardInterfaceService.read();
18573
- await docClipboardService.paste(clipboardItems);
18866
+ await commandService.executeCommand(DocPasteCommand.id);
18574
18867
  finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
18575
18868
  return;
18576
18869
  }
18577
18870
  if (commandId === DocTableDeleteTableCommand.id) docSelectionManagerService.replaceTextRanges([tableRange], false);
18578
18871
  else if (params.id === "doc.menu.insert-bellow" || commandId !== "doc.menu.insert-bellow") docSelectionManagerService.replaceTextRanges([afterTableRange], false);
18579
- if (commandService && commandId) commandService.executeCommand(commandId, commandParams);
18872
+ if (commandService && commandId) commandService.executeCommand(commandId, commandId === DocTableDeleteTableCommand.id ? {
18873
+ ...commandParams,
18874
+ targetRange: tableRange
18875
+ } : commandParams);
18580
18876
  finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
18581
18877
  return;
18582
18878
  }
@@ -18965,9 +19261,11 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
18965
19261
  RightInsertColumnDoubleIcon: _univerjs_icons.RightInsertColumnDoubleIcon,
18966
19262
  RightJustifyingIcon: _univerjs_icons.RightJustifyingIcon,
18967
19263
  ShapeIcon: _univerjs_icons.ShapeIcon,
19264
+ SmileIcon: _univerjs_icons.SmileIcon,
18968
19265
  StrikethroughIcon: _univerjs_icons.StrikethroughIcon,
18969
19266
  SubscriptIcon: _univerjs_icons.SubscriptIcon,
18970
19267
  SuperscriptIcon: _univerjs_icons.SuperscriptIcon,
19268
+ SymbolsIcon: _univerjs_icons.SymbolsIcon,
18971
19269
  TitleTypeIcon,
18972
19270
  SubtitleTypeIcon,
18973
19271
  TodoListDoubleIcon: _univerjs_icons.TodoListDoubleIcon,
@@ -21376,6 +21674,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
21376
21674
  ReplaceTextRunsCommand,
21377
21675
  ReplaceSelectionCommand,
21378
21676
  InsertCustomRangeCommand,
21677
+ InsertSpecialCharacterCommand,
21379
21678
  SetParagraphNamedStyleCommand,
21380
21679
  QuickHeadingCommand,
21381
21680
  DocCopyCurrentParagraphCommand,