@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 +363 -64
- package/lib/es/index.js +367 -68
- package/lib/index.css +0 -8
- package/lib/index.js +367 -68
- package/lib/types/basics/paragraph.d.ts +1 -0
- package/lib/types/commands/commands/insert-special-character.command.d.ts +19 -0
- package/lib/types/commands/commands/table/doc-table-delete.command.d.ts +2 -0
- package/lib/types/index.d.ts +2 -1
- package/lib/types/menu/menu.d.ts +4 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +3 -2
- package/lib/types/services/clipboard/doc-paste-mutation-adapter.service.d.ts +6 -1
- package/lib/types/services/float-menu.service.d.ts +5 -2
- package/lib/types/services/selection/convert-text-range.d.ts +1 -1
- package/lib/types/services/selection/doc-selection-render.service.d.ts +2 -0
- package/lib/types/views/ParagraphMenu.d.ts +1 -0
- package/lib/types/views/float-toolbar/FloatToolbar.d.ts +10 -3
- package/lib/umd/index.js +9 -9
- package/package.json +9 -9
package/lib/es/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { BaselineOffset, BlockType, BooleanNumber, BuildTextUtils, COLORS, ColorKit, ColumnSeparatorType, CommandType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOC_RANGE_TYPE, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, DeleteDirection, DependentOn, Direction, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentBlockType, DocumentFlavor, DrawingTypeEnum, EDITOR_ACTIVATED, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_DOC, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR, HorizontalAlign, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IUndoRedoService, IUniverInstanceService, ImageSourceType, Inject, Injector, InterceptorManager, JSONX, LRUMap, LocaleService, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MemoryCursor, ModernDocumentWidthMode, NAMED_STYLE_MAP, NamedStyleType, ObjectRelativeFromH, ObjectRelativeFromV, Optional, PAGE_SIZE, PAPER_TYPES, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, PresetListType, QuickListTypeMap, RANGE_DIRECTION, Rectangle, RedoCommand, RxDisposable, SHEET_EDITOR_UNITS, SectionType, SliceBodyType, SpacingRule, TableAlignmentType, TableRowHeightRule, TableSizeType, TableTextWrapType, TextX, TextXActionType, ThemeService, Tools, UndoCommand, UniverInstanceType, UpdateDocsAttributeType, VerticalAlign, checkForSubstrings, containsInteriorInsertionOffset, createIdentifier, createInterceptorKey, createInternalEditorID, createParagraphId, createSectionId, debounce, deepCompare, fromEventSubject, generateRandomId, getBlockRangeInterval, getBodySlice, getBodySliceForTextXAction, getCustomBlockIdsInSelections, getParagraphContentStartOffset, getParagraphContentStartOffsets, getPlainText, getRichTextEditPath, getSectionHeaderFooterReferenceKey, getTableRangeInterval, isCommentEditorID, isInternalEditorID, isSafeUrl, merge, mergeOverrideWithDependencies, normalizeBody, remove, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReference, resolveSectionHeaderFooterReferences, sequenceExecuteAsync, skipParseTagNames, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
2
|
import { CreateHeaderFooterCommand, DeleteTextCommand, DocBlockMoveValidatorService, DocContentInsertService, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, DocStateEmitService, EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY, HeaderFooterType, IDocStateChangeInterceptorService, InsertTextCommand, RichTextEditingMutation, SetSectionHeaderFooterLinkCommand, SetTextSelectionsOperation, UniverDocsPlugin, UpdateDocumentSectionCommand, UpdateTextCommand, buildDocTransform, consumeContentInsertRange, createDocsCustomBlockInsertMutation, createDocsCustomBlockRemoveMutation, createEmbedDocsCustomBlockData, createInsertCustomBlockActions, createRemoveCustomBlockActions, createSectionColumnProperties, generateParagraphs, getTopLevelSectionBreaks, isSheetLikeDocsCustomBlockChildType, isSheetLikeDocsCustomBlockChildType as isSheetLikeDocsCustomBlockChildType$1, resolveDocsCustomBlockSize, resolveDocsCustomBlockSize as resolveDocsCustomBlockSize$1, shouldUseInlineTextSelectionForDocsCustomBlockDrawing } from "@univerjs/docs";
|
|
3
3
|
import { CURSOR_TYPE, DeviceInputEventType, DocBackground, DocumentEditArea, DocumentSkeletonPageType, Documents, GlyphType, IRenderManagerService, Layer, LineType, Liquid, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, PageLayoutType, Path, Rect, RegularPolygon, ScrollBar, ScrollTimer, Shape, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin, Vector2, Viewport, compareDocumentSkeletonNestedPagePathOrder, documentSkeletonLineIterator, documentSkeletonTableIterator, getColor, getDocsTableRenderViewport, getDocumentSkeletonColumnPagePathInfo, getDocumentSkeletonNestedPageOffset, getLastColumn, getNextWheelZoomRatio, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getSystemHighlightColor, getTableIdAndSliceIndex, hasListGlyph, isFirstGlyph, isIndentByGlyph, parseDataStreamToTree, pixelToPt, ptToPixel, pxToNum } from "@univerjs/engine-render";
|
|
4
|
-
import { BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, ComponentManager, ContextMenuGroup, ContextMenuPanel, ContextMenuPosition, CopyCommand, CutCommand, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, ILayoutService, IMenuManagerService, IShortcutService, ISidebarService, IUIPartsService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MetaKeys, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RectPopup, RibbonInsertGroup, RibbonStartGroup, Slider, ToolbarItem, connectInjector, getMenuHiddenObservable, imageMimeTypeSet, useConfigValue, useDependency, useEvent, useObservable } from "@univerjs/ui";
|
|
5
|
-
import { BehaviorSubject, Observable, Subject, animationFrameScheduler, combineLatest, debounceTime, distinctUntilChanged, filter, first, fromEvent, map, merge as merge$1, startWith, switchMap, take, takeUntil, throttleTime } from "rxjs";
|
|
4
|
+
import { BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, ComponentManager, ContextMenuGroup, ContextMenuPanel, ContextMenuPosition, CopyCommand, CutCommand, EMOJI_PICKER_COMPONENT, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, ILayoutService, IMenuManagerService, IShortcutService, ISidebarService, IUIPartsService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MetaKeys, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RectPopup, RibbonInsertGroup, RibbonStartGroup, SYMBOL_PICKER_COMPONENT, Slider, ToolbarItem, connectInjector, getMenuHiddenObservable, imageMimeTypeSet, useConfigValue, useDependency, useEvent, useObservable } from "@univerjs/ui";
|
|
5
|
+
import { BehaviorSubject, Observable, Subject, animationFrameScheduler, combineLatest, debounceTime, distinctUntilChanged, filter, first, fromEvent, map, merge as merge$1, shareReplay, startWith, switchMap, take, takeUntil, throttleTime } from "rxjs";
|
|
6
6
|
import { bufferTime, filter as filter$1, map as map$1 } from "rxjs/operators";
|
|
7
|
-
import { Button, Checkbox, InputNumber, Select, Tooltip, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
|
|
7
|
+
import { Button, Checkbox, InputNumber, Select, Tooltip, borderClassName, clsx, resetButtonClassName, scrollbarClassName } from "@univerjs/design";
|
|
8
8
|
import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { AddImageIcon, AlignTextBothIcon, BoldIcon, CatalogueIcon, CopyDoubleIcon, CutIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DeleteTableDoubleIcon, DocSettingIcon, FontColorDoubleIcon, GridIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, HeaderFooterIcon, HorizontallyIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, KeyboardIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LineIndentDecreaseIcon, LineIndentIncreaseIcon, MenuIcon, MoreLeftIcon, MoreRightIcon, NoColorDoubleIcon, OrderIcon, PaintBucketDoubleIcon, PasteSpecialDoubleIcon, ReduceDoubleIcon, ReduceIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, ShapeIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, TextTypeIcon, TodoListDoubleIcon, UnderlineIcon, UnorderIcon } from "@univerjs/icons";
|
|
10
|
+
import { AddImageIcon, AlignTextBothIcon, BoldIcon, CatalogueIcon, CopyDoubleIcon, CutIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DeleteTableDoubleIcon, DocSettingIcon, FontColorDoubleIcon, GridIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, HeaderFooterIcon, HorizontallyIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, KeyboardIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LineIndentDecreaseIcon, LineIndentIncreaseIcon, MenuIcon, MoreLeftIcon, MoreRightIcon, NoColorDoubleIcon, OrderIcon, PaintBucketDoubleIcon, PasteSpecialDoubleIcon, ReduceDoubleIcon, ReduceIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, ShapeIcon, SmileIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, SymbolsIcon, TextTypeIcon, TodoListDoubleIcon, UnderlineIcon, UnorderIcon } from "@univerjs/icons";
|
|
11
11
|
|
|
12
12
|
//#region src/basics/docs-view-key.ts
|
|
13
13
|
/**
|
|
@@ -150,6 +150,11 @@ function deleteCustomDecorationFactory(accessor, params) {
|
|
|
150
150
|
|
|
151
151
|
//#endregion
|
|
152
152
|
//#region src/basics/paragraph.ts
|
|
153
|
+
function isTopLevelStructuralGap(dataStream, offset) {
|
|
154
|
+
const previousToken = dataStream[offset - 1];
|
|
155
|
+
const nextToken = dataStream[offset];
|
|
156
|
+
return previousToken === DataStreamTreeTokenType.BLOCK_END || previousToken === DataStreamTreeTokenType.TABLE_END || previousToken === DataStreamTreeTokenType.COLUMN_GROUP_END || nextToken === DataStreamTreeTokenType.BLOCK_START || nextToken === DataStreamTreeTokenType.TABLE_START || nextToken === DataStreamTreeTokenType.COLUMN_GROUP_START;
|
|
157
|
+
}
|
|
153
158
|
function hasParagraphInTable(paragraph, tables) {
|
|
154
159
|
return tables.some((table) => paragraph.startIndex > table.startIndex && paragraph.startIndex < table.endIndex);
|
|
155
160
|
}
|
|
@@ -523,11 +528,6 @@ const BreakLineCommand = {
|
|
|
523
528
|
return Boolean(result);
|
|
524
529
|
}
|
|
525
530
|
};
|
|
526
|
-
function isTopLevelStructuralGap(dataStream, offset) {
|
|
527
|
-
const previousToken = dataStream[offset - 1];
|
|
528
|
-
const nextToken = dataStream[offset];
|
|
529
|
-
return previousToken === DataStreamTreeTokenType.BLOCK_END || previousToken === DataStreamTreeTokenType.TABLE_END || previousToken === DataStreamTreeTokenType.COLUMN_GROUP_END || nextToken === DataStreamTreeTokenType.BLOCK_START || nextToken === DataStreamTreeTokenType.TABLE_START || nextToken === DataStreamTreeTokenType.COLUMN_GROUP_START;
|
|
530
|
-
}
|
|
531
531
|
|
|
532
532
|
//#endregion
|
|
533
533
|
//#region src/services/clipboard/doc-paste-mutation-adapter.service.ts
|
|
@@ -1081,7 +1081,7 @@ const InnerPasteCommand = {
|
|
|
1081
1081
|
id: "doc.command.inner-paste",
|
|
1082
1082
|
type: CommandType.COMMAND,
|
|
1083
1083
|
handler: async (accessor, params) => {
|
|
1084
|
-
var _docDataModel$getSelf, _body$tables, _body$customBlocks;
|
|
1084
|
+
var _docDataModel$getSelf, _body$tables, _body$customBlocks, _body$blockRanges;
|
|
1085
1085
|
const { segmentId, textRanges, doc } = params;
|
|
1086
1086
|
const commandService = accessor.get(ICommandService);
|
|
1087
1087
|
const undoRedoService = accessor.get(IUndoRedoService);
|
|
@@ -1115,6 +1115,7 @@ const InnerPasteCommand = {
|
|
|
1115
1115
|
const resourceMutationGroups = [];
|
|
1116
1116
|
const hasTable = !!((_body$tables = body.tables) === null || _body$tables === void 0 ? void 0 : _body$tables.length);
|
|
1117
1117
|
const hasCustomBlock = !!((_body$customBlocks = body.customBlocks) === null || _body$customBlocks === void 0 ? void 0 : _body$customBlocks.length);
|
|
1118
|
+
const hasBlockRange = !!((_body$blockRanges = body.blockRanges) === null || _body$blockRanges === void 0 ? void 0 : _body$blockRanges.length);
|
|
1118
1119
|
if (hasTable && segmentId) return false;
|
|
1119
1120
|
if (hasTable && hasRangeInTable(selections)) return false;
|
|
1120
1121
|
if (selections.length && (rectRanges === null || rectRanges === void 0 ? void 0 : rectRanges.length)) return false;
|
|
@@ -1124,6 +1125,16 @@ const InnerPasteCommand = {
|
|
|
1124
1125
|
const { startOffset, endOffset, collapsed } = selection;
|
|
1125
1126
|
const len = startOffset - memoryCursor.cursor;
|
|
1126
1127
|
const cloneBody = Tools.deepClone(body);
|
|
1128
|
+
const blockRangeMappings = [];
|
|
1129
|
+
const customBlockMappings = [];
|
|
1130
|
+
if (hasBlockRange) cloneBody.blockRanges.forEach((targetBlockRange, index) => {
|
|
1131
|
+
const sourceBlockRange = body.blockRanges[index];
|
|
1132
|
+
targetBlockRange.blockId = generateRandomId(6);
|
|
1133
|
+
blockRangeMappings.push({
|
|
1134
|
+
sourceBlockRange,
|
|
1135
|
+
targetBlockRange
|
|
1136
|
+
});
|
|
1137
|
+
});
|
|
1127
1138
|
if (hasTable) for (const t of cloneBody.tables) {
|
|
1128
1139
|
const { tableId: oldTableId } = t;
|
|
1129
1140
|
const tableId = generateRandomId(6);
|
|
@@ -1136,7 +1147,6 @@ const InnerPasteCommand = {
|
|
|
1136
1147
|
if (hasCustomBlock && drawings) {
|
|
1137
1148
|
var _docDataModel$getSnap, _docDataModel$getSnap2;
|
|
1138
1149
|
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;
|
|
1139
|
-
const customBlockMappings = [];
|
|
1140
1150
|
for (const block of cloneBody.customBlocks) {
|
|
1141
1151
|
const { blockId } = block;
|
|
1142
1152
|
const drawingId = generateRandomId(6);
|
|
@@ -1151,21 +1161,6 @@ const InnerPasteCommand = {
|
|
|
1151
1161
|
targetDrawing: drawing
|
|
1152
1162
|
});
|
|
1153
1163
|
}
|
|
1154
|
-
if (customBlockMappings.length > 0 && pasteAdapterService) {
|
|
1155
|
-
const mutationInfos = pasteAdapterService.getPasteMutationInfos({
|
|
1156
|
-
unitId,
|
|
1157
|
-
segmentId,
|
|
1158
|
-
doc,
|
|
1159
|
-
sourceBody: body,
|
|
1160
|
-
targetBody: cloneBody,
|
|
1161
|
-
customBlockMappings
|
|
1162
|
-
});
|
|
1163
|
-
if (mutationInfos.redoMutations.length > 0 || mutationInfos.undoMutations.length > 0) {
|
|
1164
|
-
resourceRedoMutations.push(...mutationInfos.redoMutations);
|
|
1165
|
-
resourceUndoMutations.push(...mutationInfos.undoMutations);
|
|
1166
|
-
resourceMutationGroups.push(mutationInfos);
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
1164
|
customBlockMappings.forEach(({ targetBlockId, targetDrawing }) => {
|
|
1170
1165
|
const action = jsonX.insertOp(["drawings", targetBlockId], targetDrawing);
|
|
1171
1166
|
const orderAction = jsonX.insertOp(["drawingsOrder", drawingLen], targetBlockId);
|
|
@@ -1173,6 +1168,22 @@ const InnerPasteCommand = {
|
|
|
1173
1168
|
rawActions.push(orderAction);
|
|
1174
1169
|
});
|
|
1175
1170
|
}
|
|
1171
|
+
if ((blockRangeMappings.length > 0 || customBlockMappings.length > 0) && pasteAdapterService) {
|
|
1172
|
+
const mutationInfos = pasteAdapterService.getPasteMutationInfos({
|
|
1173
|
+
unitId,
|
|
1174
|
+
segmentId,
|
|
1175
|
+
doc,
|
|
1176
|
+
sourceBody: body,
|
|
1177
|
+
targetBody: cloneBody,
|
|
1178
|
+
blockRangeMappings,
|
|
1179
|
+
customBlockMappings
|
|
1180
|
+
});
|
|
1181
|
+
if (mutationInfos.redoMutations.length > 0 || mutationInfos.undoMutations.length > 0) {
|
|
1182
|
+
resourceRedoMutations.push(...mutationInfos.redoMutations);
|
|
1183
|
+
resourceUndoMutations.push(...mutationInfos.undoMutations);
|
|
1184
|
+
resourceMutationGroups.push(mutationInfos);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1176
1187
|
const customRange = getCustomRangeAtPosition((_originBody$customRan = originBody.customRanges) !== null && _originBody$customRan !== void 0 ? _originBody$customRan : [], endOffset, UNITS.includes(unitId));
|
|
1177
1188
|
const customDecorations = getCustomDecorationAtPosition((_originBody$customDec = originBody.customDecorations) !== null && _originBody$customDec !== void 0 ? _originBody$customDec : [], endOffset);
|
|
1178
1189
|
if (customRange) cloneBody.customRanges = [{
|
|
@@ -3728,6 +3739,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
3728
3739
|
this._clipboardInterfaceService = _clipboardInterfaceService;
|
|
3729
3740
|
this._docSelectionManagerService = _docSelectionManagerService;
|
|
3730
3741
|
_defineProperty(this, "_clipboardHooks", []);
|
|
3742
|
+
_defineProperty(this, "_memoryClipboardData", null);
|
|
3731
3743
|
_defineProperty(this, "_htmlToUDM", new HtmlToUDMService());
|
|
3732
3744
|
_defineProperty(this, "_umdToHtml", void 0);
|
|
3733
3745
|
this._umdToHtml = new UDMToHtmlService(docHtmlExportService);
|
|
@@ -3739,7 +3751,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
3739
3751
|
try {
|
|
3740
3752
|
var _allRanges$;
|
|
3741
3753
|
const isCopyInHeaderFooter = !!(allRanges === null || allRanges === void 0 || (_allRanges$ = allRanges[0]) === null || _allRanges$ === void 0 ? void 0 : _allRanges$.segmentId);
|
|
3742
|
-
this._setClipboardData(newSnapshotList, !isCopyInHeaderFooter && needCache);
|
|
3754
|
+
await this._setClipboardData(newSnapshotList, !isCopyInHeaderFooter && needCache);
|
|
3743
3755
|
} catch (e) {
|
|
3744
3756
|
this._logService.error("[DocClipboardService] copy failed", e);
|
|
3745
3757
|
return false;
|
|
@@ -3750,6 +3762,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
3750
3762
|
return this._cut(ranges);
|
|
3751
3763
|
}
|
|
3752
3764
|
async paste(items) {
|
|
3765
|
+
if (!(items === null || items === void 0 ? void 0 : items.length)) return this._memoryClipboardData ? this._paste(Tools.deepClone(this._memoryClipboardData)) : false;
|
|
3753
3766
|
const partDocData = await this._genDocDataFromClipboardItems(items);
|
|
3754
3767
|
return this._paste(partDocData);
|
|
3755
3768
|
}
|
|
@@ -3807,11 +3820,12 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
3807
3820
|
}
|
|
3808
3821
|
}
|
|
3809
3822
|
async _paste(docData) {
|
|
3810
|
-
var
|
|
3823
|
+
var _body$customRanges, _body$paragraphs, _currentDocument$getS;
|
|
3811
3824
|
const { body: _body } = docData;
|
|
3812
3825
|
if (_body == null) return false;
|
|
3813
3826
|
let body = normalizeBody(_body);
|
|
3814
|
-
|
|
3827
|
+
const currentDocument = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
3828
|
+
if (!currentDocument) return false;
|
|
3815
3829
|
this._clipboardHooks.forEach((hook) => {
|
|
3816
3830
|
if (hook.onBeforePaste) body = hook.onBeforePaste(body);
|
|
3817
3831
|
});
|
|
@@ -3824,6 +3838,8 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
3824
3838
|
const ranges = this._docSelectionManagerService.getTextRanges();
|
|
3825
3839
|
if (segmentId == null) this._logService.error("[DocClipboardController] segmentId does not exist!");
|
|
3826
3840
|
if (activeEndOffset == null || ranges == null) return false;
|
|
3841
|
+
const originBody = segmentId == null ? null : (_currentDocument$getS = currentDocument.getSelfOrHeaderFooterModel(segmentId)) === null || _currentDocument$getS === void 0 ? void 0 : _currentDocument$getS.getBody();
|
|
3842
|
+
if (originBody) ensureParagraphAtStructuralGap(body, originBody, ranges);
|
|
3827
3843
|
try {
|
|
3828
3844
|
let cursor = activeEndOffset;
|
|
3829
3845
|
for (const range of ranges) {
|
|
@@ -3872,7 +3888,8 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
3872
3888
|
html = embedInternalClipboardFragment(html, internalJson);
|
|
3873
3889
|
}
|
|
3874
3890
|
html = wrapClipboardHtml(html);
|
|
3875
|
-
|
|
3891
|
+
await this._clipboardInterfaceService.write(text, html, internalJson ? { [DOC_INTERNAL_FRAGMENT_MIME]: internalJson } : void 0);
|
|
3892
|
+
this._memoryClipboardData = Tools.deepClone(internalDocData);
|
|
3876
3893
|
}
|
|
3877
3894
|
addClipboardHook(hook) {
|
|
3878
3895
|
this._clipboardHooks.push(hook);
|
|
@@ -4097,6 +4114,21 @@ DocClipboardService = __decorate([
|
|
|
4097
4114
|
__decorateParam(4, Inject(DocHtmlExportService)),
|
|
4098
4115
|
__decorateParam(5, Inject(DocSelectionManagerService))
|
|
4099
4116
|
], DocClipboardService);
|
|
4117
|
+
function endsAtDocumentBoundary(dataStream) {
|
|
4118
|
+
const lastToken = dataStream[dataStream.length - 1];
|
|
4119
|
+
return lastToken === DataStreamTreeTokenType.PARAGRAPH || lastToken === DataStreamTreeTokenType.SECTION_BREAK || lastToken === DataStreamTreeTokenType.BLOCK_END || lastToken === DataStreamTreeTokenType.TABLE_END || lastToken === DataStreamTreeTokenType.COLUMN_GROUP_END;
|
|
4120
|
+
}
|
|
4121
|
+
function ensureParagraphAtStructuralGap(body, originBody, ranges) {
|
|
4122
|
+
var _body$paragraphs$map, _body$paragraphs2, _body$paragraphs3;
|
|
4123
|
+
if (endsAtDocumentBoundary(body.dataStream) || !ranges.every((range) => range.collapsed && isTopLevelStructuralGap(originBody.dataStream, range.startOffset))) return;
|
|
4124
|
+
const paragraphIndex = body.dataStream.length;
|
|
4125
|
+
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 : []);
|
|
4126
|
+
body.dataStream += DataStreamTreeTokenType.PARAGRAPH;
|
|
4127
|
+
body.paragraphs = [...(_body$paragraphs3 = body.paragraphs) !== null && _body$paragraphs3 !== void 0 ? _body$paragraphs3 : [], {
|
|
4128
|
+
startIndex: paragraphIndex,
|
|
4129
|
+
paragraphId: createParagraphId(paragraphIds)
|
|
4130
|
+
}];
|
|
4131
|
+
}
|
|
4100
4132
|
function dataUrlToFile(dataUrl, fallbackName) {
|
|
4101
4133
|
const match = /^data:([^;,]+)(;base64)?,(.*)$/i.exec(dataUrl);
|
|
4102
4134
|
if (!match) throw new Error("[DocClipboardService] invalid image data url.");
|
|
@@ -4172,8 +4204,8 @@ const DocPasteCommand = {
|
|
|
4172
4204
|
preconditions: whenDocOrEditor,
|
|
4173
4205
|
handler: async (accessor) => {
|
|
4174
4206
|
const docClipboardService = accessor.get(IDocClipboardService);
|
|
4175
|
-
const
|
|
4176
|
-
|
|
4207
|
+
const clipboardInterfaceService = accessor.get(IClipboardInterfaceService);
|
|
4208
|
+
const clipboardItems = clipboardInterfaceService.supportClipboard ? await clipboardInterfaceService.read() : [];
|
|
4177
4209
|
return docClipboardService.paste(clipboardItems);
|
|
4178
4210
|
}
|
|
4179
4211
|
};
|
|
@@ -6415,7 +6447,7 @@ var NodePositionConvertToCursor = class {
|
|
|
6415
6447
|
const rawAnchorGlyph = isStartBack ? preGlyph !== null && preGlyph !== void 0 ? preGlyph : firstGlyph : firstGlyph;
|
|
6416
6448
|
const anchorGlyph = this._getCaretGlyph(rawAnchorGlyph, glyphGroup, start_sp);
|
|
6417
6449
|
const selectedGlyphs = glyphGroup.slice(start_sp, end_sp + 1);
|
|
6418
|
-
const
|
|
6450
|
+
const isSelectionOnlyNonInlineDrawing = !collapsed && selectedGlyphs.length > 0 && selectedGlyphs.every((glyph) => this._isNonInlineDrawingGlyph(glyph));
|
|
6419
6451
|
const borderBoxStartY = startY;
|
|
6420
6452
|
const borderBoxEndY = contentHeight == null ? startY + lineHeight - marginTop - marginBottom : startY + paddingTop + contentHeight + paddingBottom;
|
|
6421
6453
|
if (start_sp === 0 && end_sp === glyphGroup.length - 1) {
|
|
@@ -6448,8 +6480,8 @@ var NodePositionConvertToCursor = class {
|
|
|
6448
6480
|
}
|
|
6449
6481
|
const clippedBorderBoxPosition = clipPositionToHorizontalRange(borderBoxPosition, this._horizontalClip);
|
|
6450
6482
|
const clippedContentBoxPosition = clipPositionToHorizontalRange(contentBoxPosition, this._horizontalClip);
|
|
6451
|
-
if (clippedBorderBoxPosition && !
|
|
6452
|
-
if (clippedContentBoxPosition && !
|
|
6483
|
+
if (clippedBorderBoxPosition && !isSelectionOnlyNonInlineDrawing) borderBoxPointGroup.push(pushToPoints(clippedBorderBoxPosition));
|
|
6484
|
+
if (clippedContentBoxPosition && !isSelectionOnlyNonInlineDrawing) contentBoxPointGroup.push(pushToPoints(clippedContentBoxPosition));
|
|
6453
6485
|
cursorList.push({
|
|
6454
6486
|
startOffset: isStartBack ? startOffset : startOffset + firstGlyph.count,
|
|
6455
6487
|
endOffset: isEndBack ? endOffset : endOffset + lastGlyph.count,
|
|
@@ -6464,7 +6496,7 @@ var NodePositionConvertToCursor = class {
|
|
|
6464
6496
|
}
|
|
6465
6497
|
_getCaretGlyph(glyph, glyphGroup, glyphIndex) {
|
|
6466
6498
|
var _this$_findTextLikeGl;
|
|
6467
|
-
if (!glyph || !this.
|
|
6499
|
+
if (!glyph || !this._isNonInlineDrawingGlyph(glyph)) return glyph;
|
|
6468
6500
|
const neighbor = (_this$_findTextLikeGl = this._findTextLikeGlyph(glyphGroup, glyphIndex - 1, -1)) !== null && _this$_findTextLikeGl !== void 0 ? _this$_findTextLikeGl : this._findTextLikeGlyph(glyphGroup, glyphIndex + 1, 1);
|
|
6469
6501
|
return neighbor !== null && neighbor !== void 0 ? neighbor : {
|
|
6470
6502
|
...glyph,
|
|
@@ -6474,13 +6506,14 @@ var NodePositionConvertToCursor = class {
|
|
|
6474
6506
|
_findTextLikeGlyph(glyphGroup, startIndex, step) {
|
|
6475
6507
|
for (let index = startIndex; index >= 0 && index < glyphGroup.length; index += step) {
|
|
6476
6508
|
const glyph = glyphGroup[index];
|
|
6477
|
-
if (!this.
|
|
6509
|
+
if (!this._isNonInlineDrawingGlyph(glyph)) return glyph;
|
|
6478
6510
|
}
|
|
6479
6511
|
}
|
|
6480
|
-
|
|
6512
|
+
_isNonInlineDrawingGlyph(glyph) {
|
|
6481
6513
|
var _this$_docSkeleton$ge, _this$_docSkeleton, _this$_docSkeleton$ge2, _this$_docSkeleton$ge3, _this$_docSkeleton$ge4, _this$_docSkeleton$ge5;
|
|
6482
6514
|
if (!(glyph === null || glyph === void 0 ? void 0 : glyph.drawingId) || glyph.streamType !== DataStreamTreeTokenType.CUSTOM_BLOCK) return false;
|
|
6483
|
-
|
|
6515
|
+
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];
|
|
6516
|
+
return (drawing === null || drawing === void 0 ? void 0 : drawing.layoutType) == null ? !shouldUseInlineTextSelectionForDocsCustomBlockDrawing(drawing) : drawing.layoutType !== PositionedObjectLayoutType.INLINE;
|
|
6484
6517
|
}
|
|
6485
6518
|
_isValidPosition(startOrigin, endOrigin) {
|
|
6486
6519
|
const { segmentPage: startPage, pageType: startPageType } = startOrigin;
|
|
@@ -8181,8 +8214,16 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
8181
8214
|
sync() {
|
|
8182
8215
|
this._updateInputPosition();
|
|
8183
8216
|
}
|
|
8217
|
+
setInputPosition(x, y) {
|
|
8218
|
+
this._positionInput(x, y);
|
|
8219
|
+
}
|
|
8184
8220
|
activate(x, y, force = false) {
|
|
8221
|
+
this._positionInput(x, y);
|
|
8222
|
+
if (force && !this._shouldPreserveExternalFocus() || !force && this.canFocusing) this.focus();
|
|
8223
|
+
}
|
|
8224
|
+
_positionInput(x, y) {
|
|
8185
8225
|
this._ensureHostContainer();
|
|
8226
|
+
this._container.style.position = "fixed";
|
|
8186
8227
|
let left = x;
|
|
8187
8228
|
let top = y;
|
|
8188
8229
|
const fixedContainer = this._container.offsetParent;
|
|
@@ -8194,7 +8235,6 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
8194
8235
|
this._container.style.left = `${left}px`;
|
|
8195
8236
|
this._container.style.top = `${top}px`;
|
|
8196
8237
|
this._container.style.zIndex = "1000";
|
|
8197
|
-
if (force && !this._shouldPreserveExternalFocus() || !force && this.canFocusing) this.focus();
|
|
8198
8238
|
}
|
|
8199
8239
|
hasFocus() {
|
|
8200
8240
|
return this._getOwnerDocument().activeElement === this._input;
|
|
@@ -9239,13 +9279,14 @@ const DocTableDeleteColumnsCommand = {
|
|
|
9239
9279
|
const DocTableDeleteTableCommand = {
|
|
9240
9280
|
id: "doc.table.delete-table",
|
|
9241
9281
|
type: CommandType.COMMAND,
|
|
9242
|
-
handler: async (accessor) => {
|
|
9243
|
-
var _docDataModel$getSelf3;
|
|
9282
|
+
handler: async (accessor, params) => {
|
|
9283
|
+
var _params$targetRange, _docDataModel$getSelf3;
|
|
9244
9284
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
9245
9285
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
9246
9286
|
const commandService = accessor.get(ICommandService);
|
|
9247
9287
|
const activeRectRanges = docSelectionManagerService.getRectRanges();
|
|
9248
|
-
const
|
|
9288
|
+
const activeTextRange = docSelectionManagerService.getActiveTextRange();
|
|
9289
|
+
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
9290
|
if (rangeInfo == null) return false;
|
|
9250
9291
|
const { segmentId } = rangeInfo;
|
|
9251
9292
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
@@ -10708,10 +10749,7 @@ function getPageSizeInModernMode(page) {
|
|
|
10708
10749
|
const { marginLeft, marginRight, marginTop, marginBottom, skeDrawings, skeTables } = page;
|
|
10709
10750
|
if (pageWidth === Number.POSITIVE_INFINITY) pageWidth = page.width + marginLeft + marginRight;
|
|
10710
10751
|
if (pageHeight === Number.POSITIVE_INFINITY) pageHeight = page.height + marginTop + marginBottom;
|
|
10711
|
-
for (const drawing of skeDrawings.values())
|
|
10712
|
-
pageWidth = Math.max(pageWidth, drawing.aLeft + drawing.width + marginLeft + marginRight);
|
|
10713
|
-
pageHeight = Math.max(pageHeight, drawing.aTop + drawing.height + marginTop + marginBottom);
|
|
10714
|
-
}
|
|
10752
|
+
for (const drawing of skeDrawings.values()) pageHeight = Math.max(pageHeight, drawing.aTop + drawing.height + marginTop + marginBottom);
|
|
10715
10753
|
for (const table of skeTables.values()) pageHeight = Math.max(pageHeight, table.top + table.height + marginTop + marginBottom);
|
|
10716
10754
|
return {
|
|
10717
10755
|
pageWidth,
|
|
@@ -11094,7 +11132,7 @@ function PageSettings(props) {
|
|
|
11094
11132
|
className: "univer-grid univer-grid-cols-3 univer-gap-2",
|
|
11095
11133
|
children: MODERN_WIDTH_OPTIONS.map((option) => /* @__PURE__ */ jsxs("button", {
|
|
11096
11134
|
type: "button",
|
|
11097
|
-
className: clsx("univer-
|
|
11135
|
+
className: clsx(resetButtonClassName, 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 }),
|
|
11098
11136
|
onClick: () => handleModernWidthChange(option),
|
|
11099
11137
|
children: [/* @__PURE__ */ jsx("span", { children: localeService.t(`docs-ui.page-settings.modern-width-${option}`) }), /* @__PURE__ */ jsxs("span", {
|
|
11100
11138
|
className: "univer-text-xs univer-font-normal univer-text-gray-400",
|
|
@@ -11585,6 +11623,54 @@ function DeleteTableMenuItemFactory(accessor) {
|
|
|
11585
11623
|
};
|
|
11586
11624
|
}
|
|
11587
11625
|
|
|
11626
|
+
//#endregion
|
|
11627
|
+
//#region src/commands/commands/insert-special-character.command.ts
|
|
11628
|
+
const InsertSpecialCharacterCommand = {
|
|
11629
|
+
id: "doc.command.insert-special-character",
|
|
11630
|
+
type: CommandType.COMMAND,
|
|
11631
|
+
handler: (accessor, params) => {
|
|
11632
|
+
var _docDataModel$getSelf, _originBody$customRan, _originBody$customDec;
|
|
11633
|
+
if (!(params === null || params === void 0 ? void 0 : params.value)) return false;
|
|
11634
|
+
const commandService = accessor.get(ICommandService);
|
|
11635
|
+
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
11636
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
11637
|
+
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
11638
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
11639
|
+
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
11640
|
+
if (!docDataModel || !activeRange) return false;
|
|
11641
|
+
const { segmentId } = activeRange;
|
|
11642
|
+
const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
11643
|
+
if (!originBody) return false;
|
|
11644
|
+
const { value } = params;
|
|
11645
|
+
const curTextRun = getTextRunAtPosition(originBody, activeRange.endOffset, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache());
|
|
11646
|
+
const curCustomRange = getCustomRangeAtPosition((_originBody$customRan = originBody.customRanges) !== null && _originBody$customRan !== void 0 ? _originBody$customRan : [], activeRange.endOffset);
|
|
11647
|
+
const curCustomDecorations = getCustomDecorationAtPosition((_originBody$customDec = originBody.customDecorations) !== null && _originBody$customDec !== void 0 ? _originBody$customDec : [], activeRange.endOffset);
|
|
11648
|
+
return commandService.executeCommand(InsertTextCommand.id, {
|
|
11649
|
+
unitId: docDataModel.getUnitId(),
|
|
11650
|
+
body: {
|
|
11651
|
+
dataStream: value,
|
|
11652
|
+
textRuns: [{
|
|
11653
|
+
...curTextRun,
|
|
11654
|
+
st: 0,
|
|
11655
|
+
ed: value.length
|
|
11656
|
+
}],
|
|
11657
|
+
customRanges: curCustomRange ? [{
|
|
11658
|
+
...curCustomRange,
|
|
11659
|
+
startIndex: 0,
|
|
11660
|
+
endIndex: value.length - 1
|
|
11661
|
+
}] : [],
|
|
11662
|
+
customDecorations: curCustomDecorations.map((customDecoration) => ({
|
|
11663
|
+
...customDecoration,
|
|
11664
|
+
startIndex: 0,
|
|
11665
|
+
endIndex: value.length - 1
|
|
11666
|
+
}))
|
|
11667
|
+
},
|
|
11668
|
+
range: activeRange,
|
|
11669
|
+
segmentId
|
|
11670
|
+
});
|
|
11671
|
+
}
|
|
11672
|
+
};
|
|
11673
|
+
|
|
11588
11674
|
//#endregion
|
|
11589
11675
|
//#region src/views/const.ts
|
|
11590
11676
|
/**
|
|
@@ -11749,16 +11835,22 @@ function getInsertTableHiddenObservable(accessor) {
|
|
|
11749
11835
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
11750
11836
|
const renderManagerService = accessor.get(IRenderManagerService);
|
|
11751
11837
|
return new Observable((subscriber) => {
|
|
11838
|
+
let editAreaSubscription = null;
|
|
11752
11839
|
const subscription = univerInstanceService.focused$.subscribe((unitId) => {
|
|
11840
|
+
editAreaSubscription === null || editAreaSubscription === void 0 || editAreaSubscription.unsubscribe();
|
|
11841
|
+
editAreaSubscription = null;
|
|
11753
11842
|
if (unitId == null) return subscriber.next(true);
|
|
11754
11843
|
if (univerInstanceService.getUnitType(unitId) !== UniverInstanceType.UNIVER_DOC) return subscriber.next(true);
|
|
11755
11844
|
const currentRender = renderManagerService.getRenderById(unitId);
|
|
11756
11845
|
if (currentRender == null) return subscriber.next(true);
|
|
11757
|
-
currentRender.with(DocSkeletonManagerService).getViewModel().editAreaChange$.subscribe((editArea) => {
|
|
11846
|
+
editAreaSubscription = currentRender.with(DocSkeletonManagerService).getViewModel().editAreaChange$.subscribe((editArea) => {
|
|
11758
11847
|
subscriber.next(editArea === DocumentEditArea.HEADER || editArea === DocumentEditArea.FOOTER);
|
|
11759
11848
|
});
|
|
11760
11849
|
});
|
|
11761
|
-
return () =>
|
|
11850
|
+
return () => {
|
|
11851
|
+
editAreaSubscription === null || editAreaSubscription === void 0 || editAreaSubscription.unsubscribe();
|
|
11852
|
+
subscription.unsubscribe();
|
|
11853
|
+
};
|
|
11762
11854
|
});
|
|
11763
11855
|
}
|
|
11764
11856
|
function disableMenuWhenHeaderFooterEditing(accessor) {
|
|
@@ -11824,9 +11916,8 @@ function getHeaderFooterMenuHiddenObservable(accessor) {
|
|
|
11824
11916
|
subscriber.next(documentFlavor !== DocumentFlavor.TRADITIONAL);
|
|
11825
11917
|
});
|
|
11826
11918
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
11827
|
-
if (docDataModel == null) return subscriber.next(true);
|
|
11828
11919
|
const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
|
|
11829
|
-
subscriber.next(documentFlavor !== DocumentFlavor.TRADITIONAL);
|
|
11920
|
+
subscriber.next(docDataModel == null || documentFlavor !== DocumentFlavor.TRADITIONAL);
|
|
11830
11921
|
return () => {
|
|
11831
11922
|
subscription0.dispose();
|
|
11832
11923
|
subscription.unsubscribe();
|
|
@@ -11903,6 +11994,42 @@ function disableMenuWhenNoDocRange(accessor) {
|
|
|
11903
11994
|
return () => subscription.unsubscribe();
|
|
11904
11995
|
});
|
|
11905
11996
|
}
|
|
11997
|
+
const DOC_INSERT_EMOJI_MENU_ID = "doc.menu.insert-emoji";
|
|
11998
|
+
const DOC_INSERT_SYMBOL_MENU_ID = "doc.menu.insert-symbol";
|
|
11999
|
+
function EmojiPickerMenuItemFactory(accessor) {
|
|
12000
|
+
return {
|
|
12001
|
+
id: DOC_INSERT_EMOJI_MENU_ID,
|
|
12002
|
+
type: MenuItemType.SELECTOR,
|
|
12003
|
+
icon: "SmileIcon",
|
|
12004
|
+
tooltip: "ui.emojiPicker.emojis",
|
|
12005
|
+
selectionsCommandId: InsertSpecialCharacterCommand.id,
|
|
12006
|
+
selections: [{ label: {
|
|
12007
|
+
name: EMOJI_PICKER_COMPONENT,
|
|
12008
|
+
hoverable: false,
|
|
12009
|
+
selectable: false,
|
|
12010
|
+
props: { embedded: true }
|
|
12011
|
+
} }],
|
|
12012
|
+
disabled$: disableMenuWhenNoDocRange(accessor),
|
|
12013
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
12014
|
+
};
|
|
12015
|
+
}
|
|
12016
|
+
function SymbolPickerMenuItemFactory(accessor) {
|
|
12017
|
+
return {
|
|
12018
|
+
id: DOC_INSERT_SYMBOL_MENU_ID,
|
|
12019
|
+
type: MenuItemType.SELECTOR,
|
|
12020
|
+
icon: "SymbolsIcon",
|
|
12021
|
+
tooltip: "ui.emojiPicker.symbols",
|
|
12022
|
+
selectionsCommandId: InsertSpecialCharacterCommand.id,
|
|
12023
|
+
selections: [{ label: {
|
|
12024
|
+
name: SYMBOL_PICKER_COMPONENT,
|
|
12025
|
+
hoverable: false,
|
|
12026
|
+
selectable: false,
|
|
12027
|
+
props: { embedded: true }
|
|
12028
|
+
} }],
|
|
12029
|
+
disabled$: disableMenuWhenNoDocRange(accessor),
|
|
12030
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
12031
|
+
};
|
|
12032
|
+
}
|
|
11906
12033
|
function isTextRangeInAnyBlockRange(document, range) {
|
|
11907
12034
|
var _document$getBody$blo2, _document$getBody2;
|
|
11908
12035
|
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 : [];
|
|
@@ -12563,7 +12690,10 @@ function AlignMenuItemFactory(accessor) {
|
|
|
12563
12690
|
});
|
|
12564
12691
|
calc();
|
|
12565
12692
|
return disposable.dispose;
|
|
12566
|
-
})
|
|
12693
|
+
}).pipe(distinctUntilChanged(), shareReplay({
|
|
12694
|
+
bufferSize: 1,
|
|
12695
|
+
refCount: true
|
|
12696
|
+
}));
|
|
12567
12697
|
return {
|
|
12568
12698
|
id: AlignOperationCommand.id,
|
|
12569
12699
|
type: MenuItemType.SELECTOR,
|
|
@@ -13409,42 +13539,87 @@ const menuSchema = {
|
|
|
13409
13539
|
[RibbonStartGroup.FORMAT]: {
|
|
13410
13540
|
[SetInlineFormatBoldCommand.id]: {
|
|
13411
13541
|
order: 0,
|
|
13542
|
+
gridLayout: {
|
|
13543
|
+
row: 2,
|
|
13544
|
+
column: 1
|
|
13545
|
+
},
|
|
13412
13546
|
menuItemFactory: BoldMenuItemFactory
|
|
13413
13547
|
},
|
|
13414
13548
|
[SetInlineFormatItalicCommand.id]: {
|
|
13415
13549
|
order: 1,
|
|
13550
|
+
gridLayout: {
|
|
13551
|
+
row: 2,
|
|
13552
|
+
column: 2
|
|
13553
|
+
},
|
|
13416
13554
|
menuItemFactory: ItalicMenuItemFactory
|
|
13417
13555
|
},
|
|
13418
13556
|
[SetInlineFormatUnderlineCommand.id]: {
|
|
13419
13557
|
order: 2,
|
|
13558
|
+
gridLayout: {
|
|
13559
|
+
row: 2,
|
|
13560
|
+
column: 3
|
|
13561
|
+
},
|
|
13420
13562
|
menuItemFactory: UnderlineMenuItemFactory
|
|
13421
13563
|
},
|
|
13422
13564
|
[SetInlineFormatStrikethroughCommand.id]: {
|
|
13423
13565
|
order: 3,
|
|
13566
|
+
gridLayout: {
|
|
13567
|
+
row: 2,
|
|
13568
|
+
column: 4
|
|
13569
|
+
},
|
|
13424
13570
|
menuItemFactory: StrikeThroughMenuItemFactory
|
|
13425
13571
|
},
|
|
13426
13572
|
[SetInlineFormatSubscriptCommand.id]: {
|
|
13427
13573
|
order: 4,
|
|
13574
|
+
gridLayout: {
|
|
13575
|
+
row: 2,
|
|
13576
|
+
column: 5
|
|
13577
|
+
},
|
|
13428
13578
|
menuItemFactory: SubscriptMenuItemFactory
|
|
13429
13579
|
},
|
|
13430
13580
|
[SetInlineFormatSuperscriptCommand.id]: {
|
|
13431
13581
|
order: 5,
|
|
13582
|
+
gridLayout: {
|
|
13583
|
+
row: 2,
|
|
13584
|
+
column: 6
|
|
13585
|
+
},
|
|
13432
13586
|
menuItemFactory: SuperscriptMenuItemFactory
|
|
13433
13587
|
},
|
|
13434
13588
|
[SetParagraphNamedStyleCommand.id]: {
|
|
13435
13589
|
order: 5.5,
|
|
13590
|
+
gridLayout: {
|
|
13591
|
+
row: 1,
|
|
13592
|
+
column: 1,
|
|
13593
|
+
columnSpan: 2,
|
|
13594
|
+
width: 100
|
|
13595
|
+
},
|
|
13436
13596
|
menuItemFactory: HeadingSelectorMenuItemFactory
|
|
13437
13597
|
},
|
|
13438
13598
|
[SetInlineFormatFontSizeCommand.id]: {
|
|
13439
13599
|
order: 6,
|
|
13600
|
+
gridLayout: {
|
|
13601
|
+
row: 1,
|
|
13602
|
+
column: 7,
|
|
13603
|
+
width: 64
|
|
13604
|
+
},
|
|
13440
13605
|
menuItemFactory: FontSizeSelectorMenuItemFactory
|
|
13441
13606
|
},
|
|
13442
13607
|
[SetInlineFormatFontFamilyCommand.id]: {
|
|
13443
13608
|
order: 7,
|
|
13609
|
+
gridLayout: {
|
|
13610
|
+
row: 1,
|
|
13611
|
+
column: 3,
|
|
13612
|
+
columnSpan: 4,
|
|
13613
|
+
width: 160
|
|
13614
|
+
},
|
|
13444
13615
|
menuItemFactory: FontFamilySelectorMenuItemFactory
|
|
13445
13616
|
},
|
|
13446
13617
|
[SetInlineFormatTextColorCommand.id]: {
|
|
13447
13618
|
order: 8,
|
|
13619
|
+
gridLayout: {
|
|
13620
|
+
row: 2,
|
|
13621
|
+
column: 7
|
|
13622
|
+
},
|
|
13448
13623
|
menuItemFactory: TextColorSelectorMenuItemFactory,
|
|
13449
13624
|
[ResetInlineFormatTextColorCommand.id]: {
|
|
13450
13625
|
order: 0,
|
|
@@ -13453,6 +13628,10 @@ const menuSchema = {
|
|
|
13453
13628
|
},
|
|
13454
13629
|
[SetInlineFormatTextBackgroundColorCommand.id]: {
|
|
13455
13630
|
order: 9,
|
|
13631
|
+
gridLayout: {
|
|
13632
|
+
row: 2,
|
|
13633
|
+
column: 8
|
|
13634
|
+
},
|
|
13456
13635
|
menuItemFactory: BackgroundColorSelectorMenuItemFactory,
|
|
13457
13636
|
[ResetInlineFormatTextBackgroundColorCommand.id]: {
|
|
13458
13637
|
order: 0,
|
|
@@ -13463,32 +13642,66 @@ const menuSchema = {
|
|
|
13463
13642
|
[RibbonStartGroup.LAYOUT]: {
|
|
13464
13643
|
[AlignOperationCommand.id]: {
|
|
13465
13644
|
order: 2,
|
|
13645
|
+
gridLayout: {
|
|
13646
|
+
row: 1,
|
|
13647
|
+
column: 1
|
|
13648
|
+
},
|
|
13466
13649
|
menuItemFactory: AlignMenuItemFactory
|
|
13467
13650
|
},
|
|
13468
13651
|
[OrderListCommand.id]: {
|
|
13469
13652
|
order: 7,
|
|
13653
|
+
gridLayout: {
|
|
13654
|
+
row: 2,
|
|
13655
|
+
column: 1
|
|
13656
|
+
},
|
|
13470
13657
|
menuItemFactory: OrderListMenuItemFactory
|
|
13471
13658
|
},
|
|
13472
13659
|
[BulletListCommand.id]: {
|
|
13473
13660
|
order: 8,
|
|
13661
|
+
gridLayout: {
|
|
13662
|
+
row: 1,
|
|
13663
|
+
column: 2
|
|
13664
|
+
},
|
|
13474
13665
|
menuItemFactory: BulletListMenuItemFactory
|
|
13475
13666
|
},
|
|
13476
13667
|
[CheckListCommand.id]: {
|
|
13477
13668
|
order: 9,
|
|
13669
|
+
gridLayout: {
|
|
13670
|
+
row: 2,
|
|
13671
|
+
column: 2
|
|
13672
|
+
},
|
|
13478
13673
|
menuItemFactory: CheckListMenuItemFactory
|
|
13479
13674
|
},
|
|
13480
13675
|
[OpenHeaderFooterPanelCommand.id]: {
|
|
13481
13676
|
order: 10,
|
|
13677
|
+
gridLayout: {
|
|
13678
|
+
row: 1,
|
|
13679
|
+
column: 3,
|
|
13680
|
+
rowSpan: 2,
|
|
13681
|
+
showLabel: true
|
|
13682
|
+
},
|
|
13482
13683
|
menuItemFactory: HeaderFooterMenuItemFactory
|
|
13483
13684
|
},
|
|
13484
13685
|
[DocOpenPageSettingCommand.id]: {
|
|
13485
13686
|
order: 12,
|
|
13687
|
+
gridLayout: {
|
|
13688
|
+
row: 1,
|
|
13689
|
+
column: 4,
|
|
13690
|
+
rowSpan: 2,
|
|
13691
|
+
showLabel: true
|
|
13692
|
+
},
|
|
13486
13693
|
menuItemFactory: PageSettingMenuItemFactory
|
|
13487
13694
|
}
|
|
13488
13695
|
},
|
|
13489
13696
|
[RibbonInsertGroup.MEDIA]: {
|
|
13490
13697
|
[TABLE_MENU_ID]: {
|
|
13491
13698
|
order: 2,
|
|
13699
|
+
gridLayout: {
|
|
13700
|
+
row: 1,
|
|
13701
|
+
column: 1,
|
|
13702
|
+
rowSpan: 2,
|
|
13703
|
+
showLabel: true
|
|
13704
|
+
},
|
|
13492
13705
|
menuItemFactory: TableMenuFactory,
|
|
13493
13706
|
[DocCreateTableOperation.id]: {
|
|
13494
13707
|
order: 0,
|
|
@@ -13497,7 +13710,29 @@ const menuSchema = {
|
|
|
13497
13710
|
},
|
|
13498
13711
|
[HorizontalLineCommand.id]: {
|
|
13499
13712
|
order: 3,
|
|
13713
|
+
gridLayout: {
|
|
13714
|
+
row: 1,
|
|
13715
|
+
column: 2,
|
|
13716
|
+
rowSpan: 2,
|
|
13717
|
+
showLabel: true
|
|
13718
|
+
},
|
|
13500
13719
|
menuItemFactory: HorizontalLineFactory
|
|
13720
|
+
},
|
|
13721
|
+
[DOC_INSERT_EMOJI_MENU_ID]: {
|
|
13722
|
+
order: 4,
|
|
13723
|
+
gridLayout: {
|
|
13724
|
+
row: 1,
|
|
13725
|
+
column: 3
|
|
13726
|
+
},
|
|
13727
|
+
menuItemFactory: EmojiPickerMenuItemFactory
|
|
13728
|
+
},
|
|
13729
|
+
[DOC_INSERT_SYMBOL_MENU_ID]: {
|
|
13730
|
+
order: 5,
|
|
13731
|
+
gridLayout: {
|
|
13732
|
+
row: 2,
|
|
13733
|
+
column: 3
|
|
13734
|
+
},
|
|
13735
|
+
menuItemFactory: SymbolPickerMenuItemFactory
|
|
13501
13736
|
}
|
|
13502
13737
|
},
|
|
13503
13738
|
[ContextMenuPosition.MAIN_AREA]: {
|
|
@@ -13855,6 +14090,13 @@ const menuSchema = {
|
|
|
13855
14090
|
order: 0,
|
|
13856
14091
|
menuItemFactory: InsertDefaultTableMenuFactory
|
|
13857
14092
|
}
|
|
14093
|
+
},
|
|
14094
|
+
format: {
|
|
14095
|
+
order: 3,
|
|
14096
|
+
[DocPasteCommand.id]: {
|
|
14097
|
+
order: 0,
|
|
14098
|
+
menuItemFactory: PasteMenuFactory
|
|
14099
|
+
}
|
|
13858
14100
|
}
|
|
13859
14101
|
},
|
|
13860
14102
|
[DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID]: {
|
|
@@ -13984,8 +14226,12 @@ const menuSchema = {
|
|
|
13984
14226
|
order: 1,
|
|
13985
14227
|
menuItemFactory: CopyCurrentParagraphMenuItemFactory
|
|
13986
14228
|
},
|
|
13987
|
-
[
|
|
14229
|
+
[DocPasteCommand.id]: {
|
|
13988
14230
|
order: 2,
|
|
14231
|
+
menuItemFactory: PasteMenuFactory
|
|
14232
|
+
},
|
|
14233
|
+
[DeleteCurrentParagraphCommand.id]: {
|
|
14234
|
+
order: 3,
|
|
13989
14235
|
menuItemFactory: DeleteCurrentParagraphMenuItemFactory
|
|
13990
14236
|
}
|
|
13991
14237
|
},
|
|
@@ -15835,7 +16081,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
|
|
|
15835
16081
|
//#endregion
|
|
15836
16082
|
//#region package.json
|
|
15837
16083
|
var name = "@univerjs/docs-ui";
|
|
15838
|
-
var version = "1.0.0-alpha.
|
|
16084
|
+
var version = "1.0.0-alpha.7";
|
|
15839
16085
|
|
|
15840
16086
|
//#endregion
|
|
15841
16087
|
//#region src/commands/commands/doc-paragraph-setting.command.ts
|
|
@@ -15913,19 +16159,27 @@ const DEFAULT_AVALIABLE_MENUS = [
|
|
|
15913
16159
|
SetInlineFormatSubscriptCommand.id,
|
|
15914
16160
|
SetInlineFormatSuperscriptCommand.id,
|
|
15915
16161
|
SetInlineFormatTextColorCommand.id,
|
|
15916
|
-
|
|
16162
|
+
{
|
|
16163
|
+
id: SetInlineFormatTextBackgroundColorCommand.id,
|
|
16164
|
+
iconColor: "var(--univer-primary-600)"
|
|
16165
|
+
}
|
|
15917
16166
|
];
|
|
15918
16167
|
function resolveFloatToolbarMenus(menuManagerService, avaliableMenus) {
|
|
15919
16168
|
const floatToolbarMenus = menuManagerService.getMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION);
|
|
15920
16169
|
const flatMenus = [...menuManagerService.getFlatMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION), ...menuManagerService.getFlatMenuByPositionKey(MenuManagerPosition.RIBBON)];
|
|
15921
16170
|
const menus = [];
|
|
15922
|
-
|
|
15923
|
-
|
|
15924
|
-
|
|
16171
|
+
const menuIds = avaliableMenus.map((config) => typeof config === "string" ? config : config.id);
|
|
16172
|
+
for (const config of avaliableMenus) {
|
|
16173
|
+
const menuId = typeof config === "string" ? config : config.id;
|
|
16174
|
+
const item = flatMenus.find((item) => item.key === menuId);
|
|
16175
|
+
if (item) menus.push(typeof config === "string" ? item : {
|
|
16176
|
+
...item,
|
|
16177
|
+
iconColor: config.iconColor
|
|
16178
|
+
});
|
|
15925
16179
|
}
|
|
15926
16180
|
return {
|
|
15927
16181
|
menus,
|
|
15928
|
-
extraMenus: floatToolbarMenus.filter((item) => item.item && !
|
|
16182
|
+
extraMenus: floatToolbarMenus.filter((item) => item.item && !menuIds.includes(item.key))
|
|
15929
16183
|
};
|
|
15930
16184
|
}
|
|
15931
16185
|
function FloatToolbar(props) {
|
|
@@ -15950,7 +16204,10 @@ function FloatToolbar(props) {
|
|
|
15950
16204
|
children: [
|
|
15951
16205
|
menus.map((groupItem) => groupItem.item && /* @__PURE__ */ jsx("div", {
|
|
15952
16206
|
className: "univer-flex univer-flex-nowrap univer-gap-2 univer-px-2",
|
|
15953
|
-
children: /* @__PURE__ */ jsx(ToolbarItem, {
|
|
16207
|
+
children: /* @__PURE__ */ jsx(ToolbarItem, {
|
|
16208
|
+
...groupItem.item,
|
|
16209
|
+
iconColor: groupItem.iconColor
|
|
16210
|
+
}, groupItem.key)
|
|
15954
16211
|
}, groupItem.key)),
|
|
15955
16212
|
extraMenus.length > 0 && /* @__PURE__ */ jsx("div", { className: "univer-my-1 univer-w-px univer-bg-gray-200 dark:univer-bg-gray-700" }),
|
|
15956
16213
|
extraMenus.map((groupItem) => groupItem.item && /* @__PURE__ */ jsx("div", {
|
|
@@ -16901,14 +17158,16 @@ function isInSameLine(startNodePosition, endNodePosition) {
|
|
|
16901
17158
|
}
|
|
16902
17159
|
const SKIP_SYMBOLS = [DataStreamTreeTokenType.CUSTOM_BLOCK, DataStreamTreeTokenType.PARAGRAPH];
|
|
16903
17160
|
let DocFloatMenuService = class DocFloatMenuService extends Disposable {
|
|
16904
|
-
constructor(_context, _docSelectionManagerService, _docCanvasPopManagerService, _univerInstanceService, _docSelectionRenderService) {
|
|
17161
|
+
constructor(_context, _docSelectionManagerService, _docCanvasPopManagerService, _univerInstanceService, _docSelectionRenderService, _contextService) {
|
|
16905
17162
|
super();
|
|
16906
17163
|
this._context = _context;
|
|
16907
17164
|
this._docSelectionManagerService = _docSelectionManagerService;
|
|
16908
17165
|
this._docCanvasPopManagerService = _docCanvasPopManagerService;
|
|
16909
17166
|
this._univerInstanceService = _univerInstanceService;
|
|
16910
17167
|
this._docSelectionRenderService = _docSelectionRenderService;
|
|
17168
|
+
this._contextService = _contextService;
|
|
16911
17169
|
_defineProperty(this, "_floatMenu", null);
|
|
17170
|
+
_defineProperty(this, "_suppressed", false);
|
|
16912
17171
|
if (isInternalEditorID(this._context.unitId)) return;
|
|
16913
17172
|
this._initSelectionChange();
|
|
16914
17173
|
this.disposeWithMe(() => {
|
|
@@ -16921,6 +17180,11 @@ let DocFloatMenuService = class DocFloatMenuService extends Disposable {
|
|
|
16921
17180
|
hideFloatMenu() {
|
|
16922
17181
|
this._hideFloatMenu();
|
|
16923
17182
|
}
|
|
17183
|
+
setSuppressed(suppressed) {
|
|
17184
|
+
if (this._suppressed === suppressed) return;
|
|
17185
|
+
this._suppressed = suppressed;
|
|
17186
|
+
if (suppressed) this._hideFloatMenu();
|
|
17187
|
+
}
|
|
16924
17188
|
_initSelectionChange() {
|
|
16925
17189
|
this.disposeWithMe(this._docSelectionRenderService.onSelectionStart$.subscribe(() => {
|
|
16926
17190
|
this._hideFloatMenu();
|
|
@@ -16928,6 +17192,10 @@ let DocFloatMenuService = class DocFloatMenuService extends Disposable {
|
|
|
16928
17192
|
this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe((selection) => {
|
|
16929
17193
|
const { unitId, textRanges } = selection;
|
|
16930
17194
|
if (unitId !== this._context.unitId) return;
|
|
17195
|
+
if (this._suppressed || this._contextService.getContextValue(FOCUSING_COMMON_DRAWINGS)) {
|
|
17196
|
+
this._hideFloatMenu();
|
|
17197
|
+
return;
|
|
17198
|
+
}
|
|
16931
17199
|
const range = textRanges.length > 0 && textRanges.find((range) => !range.collapsed);
|
|
16932
17200
|
if (range) {
|
|
16933
17201
|
var _this$_floatMenu, _this$_floatMenu2;
|
|
@@ -16969,7 +17237,8 @@ DocFloatMenuService = __decorate([
|
|
|
16969
17237
|
__decorateParam(1, Inject(DocSelectionManagerService)),
|
|
16970
17238
|
__decorateParam(2, Inject(DocCanvasPopManagerService)),
|
|
16971
17239
|
__decorateParam(3, Inject(IUniverInstanceService)),
|
|
16972
|
-
__decorateParam(4, Inject(DocSelectionRenderService))
|
|
17240
|
+
__decorateParam(4, Inject(DocSelectionRenderService)),
|
|
17241
|
+
__decorateParam(5, IContextService)
|
|
16973
17242
|
], DocFloatMenuService);
|
|
16974
17243
|
function isRangeInCodeBlock(documentDataModel, range) {
|
|
16975
17244
|
var _documentDataModel$ge3, _documentDataModel$ge4;
|
|
@@ -17796,6 +18065,7 @@ function getParagraphMenuBlockRangeCommandId(blockType) {
|
|
|
17796
18065
|
}
|
|
17797
18066
|
const PARAGRAPH_MENU_BLOCK_RANGE_COMMAND_IDS = new Set(PARAGRAPH_MENU_BLOCK_RANGE_TYPES.map((blockType) => getParagraphMenuBlockRangeCommandId(blockType)));
|
|
17798
18067
|
const PARAGRAPH_MENU_SELECTION_COMMAND_IDS = /* @__PURE__ */ new Set([
|
|
18068
|
+
DocPasteCommand.id,
|
|
17799
18069
|
BulletListCommand.id,
|
|
17800
18070
|
OrderListCommand.id,
|
|
17801
18071
|
CheckListCommand.id,
|
|
@@ -17889,6 +18159,7 @@ function getParagraphMenuHiddenItemIds(menuType, target, namedStyleType) {
|
|
|
17889
18159
|
if (menuType === "doc.menu.paragraph-t.insert") return [];
|
|
17890
18160
|
const hiddenIds = [...getParagraphMenuHiddenHeadingCommandIds(namedStyleType)];
|
|
17891
18161
|
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;
|
|
18162
|
+
if ((target === null || target === void 0 ? void 0 : target.kind) !== "blockRange") hiddenIds.push(DocPasteCommand.id);
|
|
17892
18163
|
if (blockType === DocumentBlockRangeType.CALLOUT) hiddenIds.push(getParagraphMenuBlockRangeCommandId(DocumentBlockRangeType.CODE), getParagraphMenuBlockRangeCommandId(DocumentBlockRangeType.QUOTE));
|
|
17893
18164
|
else if (blockType === DocumentBlockRangeType.QUOTE || blockType === DocumentBlockRangeType.CODE) hiddenIds.push(getParagraphMenuBlockRangeCommandId(DocumentBlockRangeType.CALLOUT));
|
|
17894
18165
|
return hiddenIds;
|
|
@@ -18085,6 +18356,7 @@ function getParagraphFormattingRange(target, paragraph) {
|
|
|
18085
18356
|
return getTargetSelectionRange(target, paragraph);
|
|
18086
18357
|
}
|
|
18087
18358
|
function getParagraphMenuCommandTargetRange(commandId, targetRange, formattingRange) {
|
|
18359
|
+
if (commandId === DocPasteCommand.id) return targetRange;
|
|
18088
18360
|
if (commandId && PARAGRAPH_MENU_SELECTION_COMMAND_IDS.has(commandId)) return formattingRange !== null && formattingRange !== void 0 ? formattingRange : targetRange;
|
|
18089
18361
|
return targetRange !== null && targetRange !== void 0 ? targetRange : formattingRange;
|
|
18090
18362
|
}
|
|
@@ -18104,6 +18376,17 @@ function getBlockSelectionRange(target, paragraph) {
|
|
|
18104
18376
|
segmentId: paragraph === null || paragraph === void 0 ? void 0 : paragraph.segmentId
|
|
18105
18377
|
};
|
|
18106
18378
|
}
|
|
18379
|
+
function getBlockRangeClipboardTargetRange(commandId, target, paragraph) {
|
|
18380
|
+
if ((target === null || target === void 0 ? void 0 : target.kind) !== "blockRange") return null;
|
|
18381
|
+
if (commandId === DocPasteCommand.id) return {
|
|
18382
|
+
startOffset: target.moveRange.endOffset,
|
|
18383
|
+
endOffset: target.moveRange.endOffset,
|
|
18384
|
+
collapsed: true,
|
|
18385
|
+
segmentId: paragraph === null || paragraph === void 0 ? void 0 : paragraph.segmentId
|
|
18386
|
+
};
|
|
18387
|
+
if (commandId === DocCopyCurrentParagraphCommand.id || commandId === DocCutCurrentParagraphCommand.id) return getBlockSelectionRange(target, paragraph !== null && paragraph !== void 0 ? paragraph : void 0);
|
|
18388
|
+
return null;
|
|
18389
|
+
}
|
|
18107
18390
|
function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
18108
18391
|
var _ref3, _ref4, _currentActiveTarget$, _doc$getBody$dataStre, _doc$getBody, _currentActiveTarget$2, _paragraphObj$paragra, _currentActiveTarget$3;
|
|
18109
18392
|
const [visible, setVisible] = useState(false);
|
|
@@ -18124,7 +18407,6 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
18124
18407
|
const docClipboardService = useDependency(IDocClipboardService);
|
|
18125
18408
|
const docContentInsertService = useDependency(DocContentInsertService);
|
|
18126
18409
|
const docBlockMoveValidatorService = useDependency(DocBlockMoveValidatorService);
|
|
18127
|
-
const clipboardInterfaceService = useDependency(IClipboardInterfaceService);
|
|
18128
18410
|
const layoutService = useDependency(ILayoutService);
|
|
18129
18411
|
const iconManager = useDependency(IconManager);
|
|
18130
18412
|
const anchorRef = useRef(null);
|
|
@@ -18319,7 +18601,19 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
18319
18601
|
}
|
|
18320
18602
|
if ((latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.kind) === "blockRange") {
|
|
18321
18603
|
var _latestTarget$blockRa;
|
|
18322
|
-
|
|
18604
|
+
const currentBlockCommandId = getParagraphMenuBlockRangeCommandId((_latestTarget$blockRa = latestTarget.blockRange) === null || _latestTarget$blockRa === void 0 ? void 0 : _latestTarget$blockRa.blockType);
|
|
18605
|
+
const clipboardRange = getBlockRangeClipboardTargetRange(commandId, latestTarget, activeParagraphBound);
|
|
18606
|
+
if (clipboardRange) {
|
|
18607
|
+
if (commandId === DocCopyCurrentParagraphCommand.id) await docClipboardService.copy(SliceBodyType.copy, [clipboardRange]);
|
|
18608
|
+
else if (commandId === DocCutCurrentParagraphCommand.id) await docClipboardService.cut([clipboardRange]);
|
|
18609
|
+
else {
|
|
18610
|
+
replaceSelection(clipboardRange);
|
|
18611
|
+
await executeResolvedCommand(option, clipboardRange);
|
|
18612
|
+
}
|
|
18613
|
+
finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
|
|
18614
|
+
return;
|
|
18615
|
+
}
|
|
18616
|
+
if (commandId === currentBlockCommandId) {
|
|
18323
18617
|
await unwrapActiveBlockRange();
|
|
18324
18618
|
finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
|
|
18325
18619
|
return;
|
|
@@ -18568,14 +18862,16 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
18568
18862
|
}
|
|
18569
18863
|
if (commandId === DocPasteCommand.id) {
|
|
18570
18864
|
docSelectionManagerService.replaceTextRanges([afterTableRange], false);
|
|
18571
|
-
|
|
18572
|
-
await docClipboardService.paste(clipboardItems);
|
|
18865
|
+
await commandService.executeCommand(DocPasteCommand.id);
|
|
18573
18866
|
finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
|
|
18574
18867
|
return;
|
|
18575
18868
|
}
|
|
18576
18869
|
if (commandId === DocTableDeleteTableCommand.id) docSelectionManagerService.replaceTextRanges([tableRange], false);
|
|
18577
18870
|
else if (params.id === "doc.menu.insert-bellow" || commandId !== "doc.menu.insert-bellow") docSelectionManagerService.replaceTextRanges([afterTableRange], false);
|
|
18578
|
-
if (commandService && commandId) commandService.executeCommand(commandId,
|
|
18871
|
+
if (commandService && commandId) commandService.executeCommand(commandId, commandId === DocTableDeleteTableCommand.id ? {
|
|
18872
|
+
...commandParams,
|
|
18873
|
+
targetRange: tableRange
|
|
18874
|
+
} : commandParams);
|
|
18579
18875
|
finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
|
|
18580
18876
|
return;
|
|
18581
18877
|
}
|
|
@@ -18964,9 +19260,11 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
18964
19260
|
RightInsertColumnDoubleIcon,
|
|
18965
19261
|
RightJustifyingIcon,
|
|
18966
19262
|
ShapeIcon,
|
|
19263
|
+
SmileIcon,
|
|
18967
19264
|
StrikethroughIcon,
|
|
18968
19265
|
SubscriptIcon,
|
|
18969
19266
|
SuperscriptIcon,
|
|
19267
|
+
SymbolsIcon,
|
|
18970
19268
|
TitleTypeIcon,
|
|
18971
19269
|
SubtitleTypeIcon,
|
|
18972
19270
|
TodoListDoubleIcon,
|
|
@@ -21375,6 +21673,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
|
|
|
21375
21673
|
ReplaceTextRunsCommand,
|
|
21376
21674
|
ReplaceSelectionCommand,
|
|
21377
21675
|
InsertCustomRangeCommand,
|
|
21676
|
+
InsertSpecialCharacterCommand,
|
|
21378
21677
|
SetParagraphNamedStyleCommand,
|
|
21379
21678
|
QuickHeadingCommand,
|
|
21380
21679
|
DocCopyCurrentParagraphCommand,
|