@univerjs/docs-ui 1.0.0-alpha.2 → 1.0.0-alpha.3
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 +1924 -480
- package/lib/cjs/locale/ar-SA.js +40 -19
- package/lib/cjs/locale/ca-ES.js +39 -18
- package/lib/cjs/locale/de-DE.js +40 -19
- package/lib/cjs/locale/en-US.js +23 -2
- package/lib/cjs/locale/es-ES.js +40 -19
- package/lib/cjs/locale/fa-IR.js +40 -19
- package/lib/cjs/locale/fr-FR.js +40 -19
- package/lib/cjs/locale/id-ID.js +39 -18
- package/lib/cjs/locale/it-IT.js +40 -19
- package/lib/cjs/locale/ja-JP.js +40 -19
- package/lib/cjs/locale/ko-KR.js +40 -19
- package/lib/cjs/locale/pl-PL.js +40 -19
- package/lib/cjs/locale/pt-BR.js +39 -18
- package/lib/cjs/locale/ru-RU.js +40 -19
- package/lib/cjs/locale/sk-SK.js +40 -19
- package/lib/cjs/locale/vi-VN.js +40 -19
- package/lib/cjs/locale/zh-CN.js +23 -2
- package/lib/cjs/locale/zh-HK.js +23 -2
- package/lib/cjs/locale/zh-TW.js +23 -2
- package/lib/es/index.js +1845 -476
- package/lib/es/locale/ar-SA.js +40 -19
- package/lib/es/locale/ca-ES.js +39 -18
- package/lib/es/locale/de-DE.js +40 -19
- package/lib/es/locale/en-US.js +23 -2
- package/lib/es/locale/es-ES.js +40 -19
- package/lib/es/locale/fa-IR.js +40 -19
- package/lib/es/locale/fr-FR.js +40 -19
- package/lib/es/locale/id-ID.js +39 -18
- package/lib/es/locale/it-IT.js +40 -19
- package/lib/es/locale/ja-JP.js +40 -19
- package/lib/es/locale/ko-KR.js +40 -19
- package/lib/es/locale/pl-PL.js +40 -19
- package/lib/es/locale/pt-BR.js +39 -18
- package/lib/es/locale/ru-RU.js +40 -19
- package/lib/es/locale/sk-SK.js +40 -19
- package/lib/es/locale/vi-VN.js +40 -19
- package/lib/es/locale/zh-CN.js +23 -2
- package/lib/es/locale/zh-HK.js +23 -2
- package/lib/es/locale/zh-TW.js +23 -2
- package/lib/index.css +8 -0
- package/lib/index.js +1845 -476
- package/lib/locale/ar-SA.js +40 -19
- package/lib/locale/ca-ES.js +39 -18
- package/lib/locale/de-DE.js +40 -19
- package/lib/locale/en-US.js +23 -2
- package/lib/locale/es-ES.js +40 -19
- package/lib/locale/fa-IR.js +40 -19
- package/lib/locale/fr-FR.js +40 -19
- package/lib/locale/id-ID.js +39 -18
- package/lib/locale/it-IT.js +40 -19
- package/lib/locale/ja-JP.js +40 -19
- package/lib/locale/ko-KR.js +40 -19
- package/lib/locale/pl-PL.js +40 -19
- package/lib/locale/pt-BR.js +39 -18
- package/lib/locale/ru-RU.js +40 -19
- package/lib/locale/sk-SK.js +40 -19
- package/lib/locale/vi-VN.js +40 -19
- package/lib/locale/zh-CN.js +23 -2
- package/lib/locale/zh-HK.js +23 -2
- package/lib/locale/zh-TW.js +23 -2
- package/lib/types/commands/commands/break-line.command.d.ts +4 -3
- package/lib/types/commands/commands/doc-block-move.command.d.ts +13 -1
- package/lib/types/commands/commands/doc-header-footer.command.d.ts +1 -0
- package/lib/types/commands/commands/doc-horizontal-line.command.d.ts +1 -0
- package/lib/types/commands/commands/doc-paragraph-setting.command.d.ts +1 -2
- package/lib/types/commands/commands/replace-content.command.d.ts +2 -1
- package/lib/types/commands/operations/doc-section-setting-panel.operation.d.ts +17 -0
- package/lib/types/controllers/doc-section-setting.controller.d.ts +24 -0
- package/lib/types/controllers/render-controllers/doc-input.controller.d.ts +4 -1
- package/lib/types/controllers/render-controllers/doc-selection-render.controller.d.ts +5 -1
- package/lib/types/controllers/render-controllers/doc.render-controller.d.ts +4 -1
- package/lib/types/controllers/render-controllers/zoom.render-controller.d.ts +3 -1
- package/lib/types/controllers/ui.controller.d.ts +4 -1
- package/lib/types/embed-docs-custom-block-bleed.d.ts +30 -0
- package/lib/types/embed-docs-custom-block-refresh.d.ts +28 -0
- package/lib/types/embed-docs-custom-block-scroll.d.ts +19 -0
- package/lib/types/embed-host-anchor.d.ts +45 -0
- package/lib/types/index.d.ts +16 -1
- package/lib/types/locale/en-US.d.ts +17 -0
- package/lib/types/menu/context-menu.d.ts +1 -0
- package/lib/types/menu/menu.d.ts +1 -1
- package/lib/types/services/clipboard/clipboard.service.d.ts +7 -3
- package/lib/types/services/clipboard/doc-paste-mutation-adapter.service.d.ts +47 -0
- package/lib/types/services/clipboard/html-to-udm/converter.d.ts +1 -0
- package/lib/types/services/doc-embed-integration.service.d.ts +63 -0
- package/lib/types/services/doc-popup-manager.service.d.ts +2 -0
- package/lib/types/services/docs-render.service.d.ts +1 -1
- package/lib/types/services/float-menu.service.d.ts +1 -0
- package/lib/types/services/selection/convert-text-range.d.ts +3 -0
- package/lib/types/services/selection/doc-selection-render.service.d.ts +18 -4
- package/lib/types/utils/section-header-footer.d.ts +26 -0
- package/lib/types/views/ParagraphMenu.d.ts +7 -3
- package/lib/types/views/paragraph-setting/hook/utils.d.ts +13 -3
- package/lib/types/views/paragraph-setting/line-spacing.d.ts +4 -4
- package/lib/types/views/section-setting/Setting.d.ts +16 -0
- package/lib/types/views/section-setting/component-name.d.ts +16 -0
- package/lib/types/views/section-setting/index.d.ts +16 -0
- package/lib/types/views/section-setting/use-section-setting.d.ts +43 -0
- package/lib/umd/index.js +9 -9
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +10 -11
package/lib/es/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { BaselineOffset, BlockType, BooleanNumber, BuildTextUtils, COLORS, ColorKit, 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, Inject, Injector, InterceptorManager, JSONX, LRUMap, LocaleService, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MemoryCursor, ModernDocumentWidthMode, NAMED_STYLE_MAP, NamedStyleType, ObjectRelativeFromH, ObjectRelativeFromV, PAGE_SIZE, PAPER_TYPES, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, PresetListType, QuickListTypeMap, RANGE_DIRECTION, Rectangle, RedoCommand, RxDisposable, SHEET_EDITOR_UNITS, SliceBodyType, SpacingRule, TableAlignmentType, TableRowHeightRule, TableSizeType, TableTextWrapType, TextX, TextXActionType, ThemeService, Tools, UndoCommand, UniverInstanceType, UpdateDocsAttributeType, VerticalAlign, checkForSubstrings, createIdentifier, createInterceptorKey, createInternalEditorID, createParagraphId, debounce, deepCompare, fromEventSubject, generateRandomId, getBodySlice, getPlainText, getRichTextEditPath, isCommentEditorID, isInternalEditorID, isSafeUrl, merge, mergeOverrideWithDependencies, normalizeBody, remove, sequenceExecuteAsync, skipParseTagNames, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
|
-
import { CreateHeaderFooterCommand, DeleteTextCommand, DocBlockMoveValidatorService, DocContentInsertService, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, DocStateEmitService, HeaderFooterType, IDocStateChangeInterceptorService, InsertTextCommand, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin, UpdateTextCommand, consumeContentInsertRange } from "@univerjs/docs";
|
|
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, getParagraphContentStartOffset, getParagraphContentStartOffsets, getPlainText, getRichTextEditPath, getSectionHeaderFooterReferenceKey, getTableRangeInterval, isCommentEditorID, isInternalEditorID, isSafeUrl, merge, mergeOverrideWithDependencies, normalizeBody, remove, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReference, resolveSectionHeaderFooterReferences, sequenceExecuteAsync, skipParseTagNames, toDisposable, touchDependencies } from "@univerjs/core";
|
|
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, 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
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 { ImageSourceType } from "@univerjs/drawing";
|
|
6
5
|
import { BehaviorSubject, Observable, Subject, animationFrameScheduler, combineLatest, distinctUntilChanged, filter, first, fromEvent, map, merge as merge$1, of, switchMap, take, takeUntil, throttleTime } from "rxjs";
|
|
7
6
|
import { bufferTime, filter as filter$1, map as map$1 } from "rxjs/operators";
|
|
8
7
|
import { Button, Checkbox, InputNumber, Select, Tooltip, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
|
|
9
|
-
import { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
10
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { AddImageIcon, AlignTextBothIcon, BoldIcon, CatalogueIcon, CopyDoubleIcon, CutIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DocSettingIcon, FontColorDoubleIcon, GridIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, HeaderFooterIcon, HorizontallyIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, KeyboardIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, 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, 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";
|
|
12
11
|
|
|
13
12
|
//#region src/basics/docs-view-key.ts
|
|
14
13
|
/**
|
|
@@ -431,30 +430,6 @@ DocMenuStyleService = __decorate([
|
|
|
431
430
|
|
|
432
431
|
//#endregion
|
|
433
432
|
//#region src/commands/commands/break-line.command.ts
|
|
434
|
-
function generateParagraphs(dataStream, prevParagraph, borderBottom) {
|
|
435
|
-
const paragraphs = [];
|
|
436
|
-
const existingParagraphIds = /* @__PURE__ */ new Set();
|
|
437
|
-
for (let i = 0, len = dataStream.length; i < len; i++) {
|
|
438
|
-
if (dataStream[i] !== DataStreamTreeTokenType.PARAGRAPH) continue;
|
|
439
|
-
paragraphs.push({
|
|
440
|
-
startIndex: i,
|
|
441
|
-
paragraphId: createParagraphId(existingParagraphIds)
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
if (prevParagraph) for (const paragraph of paragraphs) {
|
|
445
|
-
if (prevParagraph.bullet) paragraph.bullet = Tools.deepClone(prevParagraph.bullet);
|
|
446
|
-
if (prevParagraph.paragraphStyle) {
|
|
447
|
-
paragraph.paragraphStyle = Tools.deepClone(prevParagraph.paragraphStyle);
|
|
448
|
-
delete paragraph.paragraphStyle.borderBottom;
|
|
449
|
-
if (prevParagraph.paragraphStyle.headingId) paragraph.paragraphStyle.headingId = generateRandomId(6);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
if (borderBottom) for (const paragraph of paragraphs) {
|
|
453
|
-
if (!paragraph.paragraphStyle) paragraph.paragraphStyle = {};
|
|
454
|
-
paragraph.paragraphStyle.borderBottom = borderBottom;
|
|
455
|
-
}
|
|
456
|
-
return paragraphs;
|
|
457
|
-
}
|
|
458
433
|
const BreakLineCommand = {
|
|
459
434
|
id: "doc.command.break-line",
|
|
460
435
|
type: CommandType.COMMAND,
|
|
@@ -475,17 +450,19 @@ const BreakLineCommand = {
|
|
|
475
450
|
}]);
|
|
476
451
|
return true;
|
|
477
452
|
}
|
|
478
|
-
const { horizontalLine } = params !== null && params !== void 0 ? params : {};
|
|
453
|
+
const { horizontalLine, insertionMode = "split-paragraph" } = params !== null && params !== void 0 ? params : {};
|
|
479
454
|
const { segmentId } = activeTextRange;
|
|
480
455
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
481
456
|
const originBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId !== null && segmentId !== void 0 ? segmentId : "")) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
482
457
|
if (docDataModel == null || originBody == null) return false;
|
|
483
458
|
const unitId = docDataModel.getUnitId();
|
|
484
459
|
const { startOffset, endOffset } = activeTextRange;
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
|
|
460
|
+
const paragraphs = (_originBody$paragraph = originBody.paragraphs) !== null && _originBody$paragraph !== void 0 ? _originBody$paragraph : [];
|
|
461
|
+
const insertsAtStructuralGap = insertionMode === "insert-gap" || isTopLevelStructuralGap(originBody.dataStream, startOffset);
|
|
462
|
+
const prevParagraph = insertsAtStructuralGap ? void 0 : paragraphs.find((p) => p.startIndex >= startOffset);
|
|
463
|
+
if (!prevParagraph && !insertsAtStructuralGap) return false;
|
|
464
|
+
const isAtParagraphEnd = startOffset === (prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.startIndex);
|
|
465
|
+
const prevParagraphIndex = prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.startIndex;
|
|
489
466
|
const curTextRun = getTextRunAtPosition(originBody, endOffset, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache());
|
|
490
467
|
const insertBody = {
|
|
491
468
|
dataStream: DataStreamTreeTokenType.PARAGRAPH,
|
|
@@ -500,7 +477,7 @@ const BreakLineCommand = {
|
|
|
500
477
|
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
501
478
|
if (originBody == null) return false;
|
|
502
479
|
const { collapsed } = activeTextRange;
|
|
503
|
-
const cursorMove = insertBody.dataStream.length;
|
|
480
|
+
const cursorMove = insertsAtStructuralGap ? 0 : insertBody.dataStream.length;
|
|
504
481
|
const textRanges = [{
|
|
505
482
|
startOffset: startOffset + cursorMove,
|
|
506
483
|
endOffset: startOffset + cursorMove,
|
|
@@ -513,7 +490,8 @@ const BreakLineCommand = {
|
|
|
513
490
|
unitId,
|
|
514
491
|
actions: [],
|
|
515
492
|
textRanges,
|
|
516
|
-
debounce: true
|
|
493
|
+
debounce: true,
|
|
494
|
+
trigger: BreakLineCommand.id
|
|
517
495
|
}
|
|
518
496
|
};
|
|
519
497
|
const textX = new TextX();
|
|
@@ -532,9 +510,9 @@ const BreakLineCommand = {
|
|
|
532
510
|
const dos = BuildTextUtils.selection.delete([activeTextRange], originBody, 0, insertBody);
|
|
533
511
|
textX.push(...dos);
|
|
534
512
|
}
|
|
535
|
-
if (((_prevParagraph$bullet = prevParagraph.bullet) === null || _prevParagraph$bullet === void 0 ? void 0 : _prevParagraph$bullet.listType) === PresetListType.CHECK_LIST_CHECKED || ((_prevParagraph$paragr = prevParagraph.paragraphStyle) === null || _prevParagraph$paragr === void 0 ? void 0 : _prevParagraph$paragr.headingId)) {
|
|
513
|
+
if (prevParagraph && (((_prevParagraph$bullet = prevParagraph.bullet) === null || _prevParagraph$bullet === void 0 ? void 0 : _prevParagraph$bullet.listType) === PresetListType.CHECK_LIST_CHECKED || ((_prevParagraph$paragr = prevParagraph.paragraphStyle) === null || _prevParagraph$paragr === void 0 ? void 0 : _prevParagraph$paragr.headingId))) {
|
|
536
514
|
var _prevParagraph$paragr2;
|
|
537
|
-
if (activeTextRange.endOffset < prevParagraphIndex) textX.push({
|
|
515
|
+
if (prevParagraphIndex != null && activeTextRange.endOffset < prevParagraphIndex) textX.push({
|
|
538
516
|
t: TextXActionType.RETAIN,
|
|
539
517
|
len: prevParagraphIndex - activeTextRange.endOffset
|
|
540
518
|
});
|
|
@@ -573,6 +551,41 @@ const BreakLineCommand = {
|
|
|
573
551
|
return Boolean(result);
|
|
574
552
|
}
|
|
575
553
|
};
|
|
554
|
+
function isTopLevelStructuralGap(dataStream, offset) {
|
|
555
|
+
const previousToken = dataStream[offset - 1];
|
|
556
|
+
const nextToken = dataStream[offset];
|
|
557
|
+
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;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region src/services/clipboard/doc-paste-mutation-adapter.service.ts
|
|
562
|
+
const IDocClipboardPasteAdapterService = createIdentifier("doc.clipboard-paste-adapter.service");
|
|
563
|
+
var DocClipboardPasteAdapterService = class {
|
|
564
|
+
constructor() {
|
|
565
|
+
_defineProperty(this, "_adapters", []);
|
|
566
|
+
}
|
|
567
|
+
registerAdapter(adapter) {
|
|
568
|
+
this._adapters.push(adapter);
|
|
569
|
+
return toDisposable(() => {
|
|
570
|
+
const index = this._adapters.indexOf(adapter);
|
|
571
|
+
if (index >= 0) this._adapters.splice(index, 1);
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
getPasteMutationInfos(params) {
|
|
575
|
+
const mutationInfos = {
|
|
576
|
+
redoMutations: [],
|
|
577
|
+
undoMutations: []
|
|
578
|
+
};
|
|
579
|
+
for (const adapter of this._adapters) {
|
|
580
|
+
var _adapter$getPasteMuta;
|
|
581
|
+
const nextMutationInfos = (_adapter$getPasteMuta = adapter.getPasteMutationInfos) === null || _adapter$getPasteMuta === void 0 ? void 0 : _adapter$getPasteMuta.call(adapter, params);
|
|
582
|
+
if (!nextMutationInfos) continue;
|
|
583
|
+
mutationInfos.redoMutations.push(...nextMutationInfos.redoMutations);
|
|
584
|
+
mutationInfos.undoMutations.push(...nextMutationInfos.undoMutations);
|
|
585
|
+
}
|
|
586
|
+
return mutationInfos;
|
|
587
|
+
}
|
|
588
|
+
};
|
|
576
589
|
|
|
577
590
|
//#endregion
|
|
578
591
|
//#region src/commands/util.ts
|
|
@@ -593,6 +606,7 @@ function genEmptyTable(rowCount, colCount) {
|
|
|
593
606
|
const paragraphs = [];
|
|
594
607
|
const sectionBreaks = [];
|
|
595
608
|
const existingParagraphIds = /* @__PURE__ */ new Set();
|
|
609
|
+
const existingSectionIds = /* @__PURE__ */ new Set();
|
|
596
610
|
for (let i = 0; i < rowCount; i++) {
|
|
597
611
|
dataStream += DataStreamTreeTokenType.TABLE_ROW_START;
|
|
598
612
|
for (let j = 0; j < colCount; j++) {
|
|
@@ -606,7 +620,10 @@ function genEmptyTable(rowCount, colCount) {
|
|
|
606
620
|
spaceBelow: { v: 0 }
|
|
607
621
|
}
|
|
608
622
|
});
|
|
609
|
-
sectionBreaks.push({
|
|
623
|
+
sectionBreaks.push({
|
|
624
|
+
sectionId: createSectionId(existingSectionIds),
|
|
625
|
+
startIndex: dataStream.length - 2
|
|
626
|
+
});
|
|
610
627
|
}
|
|
611
628
|
dataStream += DataStreamTreeTokenType.TABLE_ROW_END;
|
|
612
629
|
}
|
|
@@ -711,6 +728,7 @@ function getInsertRowBody(col) {
|
|
|
711
728
|
const paragraphs = [];
|
|
712
729
|
const sectionBreaks = [];
|
|
713
730
|
const existingParagraphIds = /* @__PURE__ */ new Set();
|
|
731
|
+
const existingSectionIds = /* @__PURE__ */ new Set();
|
|
714
732
|
for (let i = 0; i < col; i++) {
|
|
715
733
|
dataStream += `${DataStreamTreeTokenType.TABLE_CELL_START}\r\n${DataStreamTreeTokenType.TABLE_CELL_END}`;
|
|
716
734
|
paragraphs.push({
|
|
@@ -722,7 +740,10 @@ function getInsertRowBody(col) {
|
|
|
722
740
|
spaceBelow: { v: 0 }
|
|
723
741
|
}
|
|
724
742
|
});
|
|
725
|
-
sectionBreaks.push({
|
|
743
|
+
sectionBreaks.push({
|
|
744
|
+
sectionId: createSectionId(existingSectionIds),
|
|
745
|
+
startIndex: dataStream.length - 2
|
|
746
|
+
});
|
|
726
747
|
}
|
|
727
748
|
dataStream += DataStreamTreeTokenType.TABLE_ROW_END;
|
|
728
749
|
return {
|
|
@@ -744,7 +765,10 @@ function getInsertColumnBody() {
|
|
|
744
765
|
spaceBelow: { v: 0 }
|
|
745
766
|
}
|
|
746
767
|
});
|
|
747
|
-
sectionBreaks.push({
|
|
768
|
+
sectionBreaks.push({
|
|
769
|
+
sectionId: createSectionId(/* @__PURE__ */ new Set()),
|
|
770
|
+
startIndex: 2
|
|
771
|
+
});
|
|
748
772
|
return {
|
|
749
773
|
dataStream,
|
|
750
774
|
paragraphs,
|
|
@@ -1101,8 +1125,10 @@ const InnerPasteCommand = {
|
|
|
1101
1125
|
var _docDataModel$getSelf, _body$tables, _body$customBlocks;
|
|
1102
1126
|
const { segmentId, textRanges, doc } = params;
|
|
1103
1127
|
const commandService = accessor.get(ICommandService);
|
|
1128
|
+
const undoRedoService = accessor.get(IUndoRedoService);
|
|
1104
1129
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
1105
1130
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
1131
|
+
const pasteAdapterService = getPasteAdapterService(accessor);
|
|
1106
1132
|
const selections = docSelectionManagerService.getTextRanges();
|
|
1107
1133
|
const rectRanges = docSelectionManagerService.getRectRanges();
|
|
1108
1134
|
const { body, tableSource, drawings } = doc;
|
|
@@ -1125,6 +1151,9 @@ const InnerPasteCommand = {
|
|
|
1125
1151
|
const textX = new TextX();
|
|
1126
1152
|
const jsonX = JSONX.getInstance();
|
|
1127
1153
|
const rawActions = [];
|
|
1154
|
+
const resourceRedoMutations = [];
|
|
1155
|
+
const resourceUndoMutations = [];
|
|
1156
|
+
const resourceMutationGroups = [];
|
|
1128
1157
|
const hasTable = !!((_body$tables = body.tables) === null || _body$tables === void 0 ? void 0 : _body$tables.length);
|
|
1129
1158
|
const hasCustomBlock = !!((_body$customBlocks = body.customBlocks) === null || _body$customBlocks === void 0 ? void 0 : _body$customBlocks.length);
|
|
1130
1159
|
if (hasTable && segmentId) return false;
|
|
@@ -1148,17 +1177,42 @@ const InnerPasteCommand = {
|
|
|
1148
1177
|
if (hasCustomBlock && drawings) {
|
|
1149
1178
|
var _docDataModel$getSnap, _docDataModel$getSnap2;
|
|
1150
1179
|
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;
|
|
1180
|
+
const customBlockMappings = [];
|
|
1151
1181
|
for (const block of cloneBody.customBlocks) {
|
|
1152
1182
|
const { blockId } = block;
|
|
1153
1183
|
const drawingId = generateRandomId(6);
|
|
1154
1184
|
block.blockId = drawingId;
|
|
1155
|
-
const
|
|
1185
|
+
const sourceDrawing = drawings[blockId];
|
|
1186
|
+
const drawing = Tools.deepClone(sourceDrawing);
|
|
1156
1187
|
drawing.drawingId = drawingId;
|
|
1157
|
-
|
|
1158
|
-
|
|
1188
|
+
customBlockMappings.push({
|
|
1189
|
+
sourceBlockId: blockId,
|
|
1190
|
+
targetBlockId: drawingId,
|
|
1191
|
+
sourceDrawing,
|
|
1192
|
+
targetDrawing: drawing
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
if (customBlockMappings.length > 0 && pasteAdapterService) {
|
|
1196
|
+
const mutationInfos = pasteAdapterService.getPasteMutationInfos({
|
|
1197
|
+
unitId,
|
|
1198
|
+
segmentId,
|
|
1199
|
+
doc,
|
|
1200
|
+
sourceBody: body,
|
|
1201
|
+
targetBody: cloneBody,
|
|
1202
|
+
customBlockMappings
|
|
1203
|
+
});
|
|
1204
|
+
if (mutationInfos.redoMutations.length > 0 || mutationInfos.undoMutations.length > 0) {
|
|
1205
|
+
resourceRedoMutations.push(...mutationInfos.redoMutations);
|
|
1206
|
+
resourceUndoMutations.push(...mutationInfos.undoMutations);
|
|
1207
|
+
resourceMutationGroups.push(mutationInfos);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
customBlockMappings.forEach(({ targetBlockId, targetDrawing }) => {
|
|
1211
|
+
const action = jsonX.insertOp(["drawings", targetBlockId], targetDrawing);
|
|
1212
|
+
const orderAction = jsonX.insertOp(["drawingsOrder", drawingLen], targetBlockId);
|
|
1159
1213
|
rawActions.push(action);
|
|
1160
1214
|
rawActions.push(orderAction);
|
|
1161
|
-
}
|
|
1215
|
+
});
|
|
1162
1216
|
}
|
|
1163
1217
|
const customRange = getCustomRangeAtPosition((_originBody$customRan = originBody.customRanges) !== null && _originBody$customRan !== void 0 ? _originBody$customRan : [], endOffset, UNITS.includes(unitId));
|
|
1164
1218
|
const customDecorations = getCustomDecorationAtPosition((_originBody$customDec = originBody.customDecorations) !== null && _originBody$customDec !== void 0 ? _originBody$customDec : [], endOffset);
|
|
@@ -1194,10 +1248,55 @@ const InnerPasteCommand = {
|
|
|
1194
1248
|
doMutation.params.actions = rawActions.reduce((acc, cur) => {
|
|
1195
1249
|
return JSONX.compose(acc, cur);
|
|
1196
1250
|
}, null);
|
|
1251
|
+
if (!executeResourceMutationGroups(resourceMutationGroups, commandService)) return false;
|
|
1252
|
+
const historyId = `doc-paste-resource:${unitId}:${Date.now()}`;
|
|
1253
|
+
let batchingDisposable = null;
|
|
1254
|
+
if (resourceRedoMutations.length > 0 || resourceUndoMutations.length > 0) {
|
|
1255
|
+
batchingDisposable = undoRedoService.__tempBatchingUndoRedo(unitId);
|
|
1256
|
+
undoRedoService.pushUndoRedo({
|
|
1257
|
+
unitID: unitId,
|
|
1258
|
+
redoMutations: resourceRedoMutations,
|
|
1259
|
+
undoMutations: resourceUndoMutations,
|
|
1260
|
+
id: historyId
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1197
1263
|
const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
1264
|
+
if (!result && batchingDisposable != null) {
|
|
1265
|
+
batchingDisposable.dispose();
|
|
1266
|
+
undoRedoService.rollback(historyId, unitId);
|
|
1267
|
+
return false;
|
|
1268
|
+
}
|
|
1269
|
+
batchingDisposable === null || batchingDisposable === void 0 || batchingDisposable.dispose();
|
|
1198
1270
|
return Boolean(result);
|
|
1199
1271
|
}
|
|
1200
1272
|
};
|
|
1273
|
+
function getPasteAdapterService(accessor) {
|
|
1274
|
+
try {
|
|
1275
|
+
return accessor.get(IDocClipboardPasteAdapterService);
|
|
1276
|
+
} catch {
|
|
1277
|
+
return null;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
function executeResourceMutationGroups(mutationGroups, commandService) {
|
|
1281
|
+
const executedUndoGroups = [];
|
|
1282
|
+
for (const mutationGroup of mutationGroups) {
|
|
1283
|
+
if (!executeMutations(mutationGroup.redoMutations, commandService)) {
|
|
1284
|
+
executeMutationGroups([...executedUndoGroups].reverse(), commandService);
|
|
1285
|
+
return false;
|
|
1286
|
+
}
|
|
1287
|
+
executedUndoGroups.push(mutationGroup.undoMutations);
|
|
1288
|
+
}
|
|
1289
|
+
return true;
|
|
1290
|
+
}
|
|
1291
|
+
function executeMutationGroups(mutationGroups, commandService) {
|
|
1292
|
+
mutationGroups.forEach((mutations) => {
|
|
1293
|
+
executeMutations(mutations, commandService);
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
function executeMutations(mutations, commandService) {
|
|
1297
|
+
for (const mutation of mutations) if (!commandService.syncExecuteCommand(mutation.id, mutation.params)) return false;
|
|
1298
|
+
return true;
|
|
1299
|
+
}
|
|
1201
1300
|
function adjustSelectionByTable(selection, tables) {
|
|
1202
1301
|
const { startOffset, endOffset } = selection;
|
|
1203
1302
|
const endsWithTable = tables.some((t) => t.startIndex === endOffset);
|
|
@@ -1613,14 +1712,11 @@ function getCursorWhenDelete(textRanges, rectRanges) {
|
|
|
1613
1712
|
}
|
|
1614
1713
|
return cursor;
|
|
1615
1714
|
}
|
|
1616
|
-
function getBlockRangeEndTokenOffset(body, blockRange) {
|
|
1617
|
-
return body.dataStream[blockRange.endIndex] === DataStreamTreeTokenType.BLOCK_END ? blockRange.endIndex : body.dataStream[blockRange.endIndex + 1] === DataStreamTreeTokenType.BLOCK_END ? blockRange.endIndex + 1 : blockRange.endIndex;
|
|
1618
|
-
}
|
|
1619
1715
|
function isDeleteOffsetInsideBlockRange(body, offset) {
|
|
1620
1716
|
var _body$blockRanges$som, _body$blockRanges;
|
|
1621
1717
|
return (_body$blockRanges$som = (_body$blockRanges = body.blockRanges) === null || _body$blockRanges === void 0 ? void 0 : _body$blockRanges.some((blockRange) => {
|
|
1622
|
-
const
|
|
1623
|
-
return
|
|
1718
|
+
const interval = getBlockRangeInterval(blockRange);
|
|
1719
|
+
return interval.startOffset < offset && offset < interval.endOffset - 1;
|
|
1624
1720
|
})) !== null && _body$blockRanges$som !== void 0 ? _body$blockRanges$som : false;
|
|
1625
1721
|
}
|
|
1626
1722
|
const DeleteLeftCommand = {
|
|
@@ -2111,6 +2207,10 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2111
2207
|
var _body$paragraphs;
|
|
2112
2208
|
return createParagraphId(new Set((_body$paragraphs = body.paragraphs) === null || _body$paragraphs === void 0 ? void 0 : _body$paragraphs.map((paragraph) => paragraph.paragraphId)));
|
|
2113
2209
|
}
|
|
2210
|
+
_createSectionId(body) {
|
|
2211
|
+
var _body$sectionBreaks;
|
|
2212
|
+
return createSectionId(new Set((_body$sectionBreaks = body.sectionBreaks) === null || _body$sectionBreaks === void 0 ? void 0 : _body$sectionBreaks.map((sectionBreak) => sectionBreak.sectionId)));
|
|
2213
|
+
}
|
|
2114
2214
|
convert(html, metaConfig = {}) {
|
|
2115
2215
|
var _pastePlugin$preproce, _pastePlugin$preproce2, _metaConfig$unitId;
|
|
2116
2216
|
const pastePlugin = HtmlToUDMService._pluginList.find((plugin) => plugin.checkPasteType(html));
|
|
@@ -2336,7 +2436,7 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2336
2436
|
if (wordListContext) paragraph.startIndex -= stripListMarkerFromCurrentParagraph(doc.body);
|
|
2337
2437
|
}
|
|
2338
2438
|
_processHtmlTable(node, doc) {
|
|
2339
|
-
var _doc$tableSource, _body$tables, _body$
|
|
2439
|
+
var _doc$tableSource, _body$tables, _body$sectionBreaks2;
|
|
2340
2440
|
const body = doc.body;
|
|
2341
2441
|
if (body.dataStream[body.dataStream.length - 1] !== "\r") {
|
|
2342
2442
|
var _body$paragraphs3;
|
|
@@ -2349,7 +2449,7 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2349
2449
|
}
|
|
2350
2450
|
(_doc$tableSource = doc.tableSource) !== null && _doc$tableSource !== void 0 || (doc.tableSource = {});
|
|
2351
2451
|
(_body$tables = body.tables) !== null && _body$tables !== void 0 || (body.tables = []);
|
|
2352
|
-
(_body$
|
|
2452
|
+
(_body$sectionBreaks2 = body.sectionBreaks) !== null && _body$sectionBreaks2 !== void 0 || (body.sectionBreaks = []);
|
|
2353
2453
|
const rows = collectHtmlTableRows(node);
|
|
2354
2454
|
const grid = buildHtmlTableGrid(rows);
|
|
2355
2455
|
const columnCount = Math.max(1, ...grid.map((row) => row.length));
|
|
@@ -2401,7 +2501,7 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2401
2501
|
});
|
|
2402
2502
|
}
|
|
2403
2503
|
_appendHtmlTableCell(cell, doc) {
|
|
2404
|
-
var _body$
|
|
2504
|
+
var _body$sectionBreaks3;
|
|
2405
2505
|
const body = doc.body;
|
|
2406
2506
|
body.dataStream += DataStreamTreeTokenType.TABLE_CELL_START;
|
|
2407
2507
|
if (cell.element && !cell.covered) this._process(cell.element, cell.element.childNodes, doc);
|
|
@@ -2409,8 +2509,11 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2409
2509
|
var _cell$element;
|
|
2410
2510
|
this._appendParagraph(doc, (_cell$element = cell.element) !== null && _cell$element !== void 0 ? _cell$element : document.createElement("td"));
|
|
2411
2511
|
}
|
|
2412
|
-
(_body$
|
|
2413
|
-
body.sectionBreaks.push({
|
|
2512
|
+
(_body$sectionBreaks3 = body.sectionBreaks) !== null && _body$sectionBreaks3 !== void 0 || (body.sectionBreaks = []);
|
|
2513
|
+
body.sectionBreaks.push({
|
|
2514
|
+
sectionId: this._createSectionId(body),
|
|
2515
|
+
startIndex: body.dataStream.length
|
|
2516
|
+
});
|
|
2414
2517
|
body.dataStream += `\n${DataStreamTreeTokenType.TABLE_CELL_END}`;
|
|
2415
2518
|
}
|
|
2416
2519
|
_processBeforeTable(node, doc) {
|
|
@@ -2476,7 +2579,7 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2476
2579
|
body.dataStream += DataStreamTreeTokenType.TABLE_ROW_END;
|
|
2477
2580
|
break;
|
|
2478
2581
|
case "TD":
|
|
2479
|
-
var _body$
|
|
2582
|
+
var _body$sectionBreaks4;
|
|
2480
2583
|
if (body.dataStream[body.dataStream.length - 1] !== "\r") {
|
|
2481
2584
|
var _body$paragraphs5;
|
|
2482
2585
|
(_body$paragraphs5 = body.paragraphs) === null || _body$paragraphs5 === void 0 || _body$paragraphs5.push({
|
|
@@ -2485,7 +2588,10 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2485
2588
|
});
|
|
2486
2589
|
body.dataStream += "\r";
|
|
2487
2590
|
}
|
|
2488
|
-
(_body$
|
|
2591
|
+
(_body$sectionBreaks4 = body.sectionBreaks) === null || _body$sectionBreaks4 === void 0 || _body$sectionBreaks4.push({
|
|
2592
|
+
sectionId: this._createSectionId(body),
|
|
2593
|
+
startIndex: body.dataStream.length
|
|
2594
|
+
});
|
|
2489
2595
|
body.dataStream += `\n${DataStreamTreeTokenType.TABLE_CELL_END}`;
|
|
2490
2596
|
break;
|
|
2491
2597
|
}
|
|
@@ -3314,7 +3420,10 @@ function convertBodyToHtml(doc) {
|
|
|
3314
3420
|
startIndex: dataStream.length - 2,
|
|
3315
3421
|
paragraphId: createParagraphId(new Set(paragraphs.map((paragraph) => paragraph.paragraphId)))
|
|
3316
3422
|
});
|
|
3317
|
-
sectionBreaks.push({
|
|
3423
|
+
sectionBreaks.push({
|
|
3424
|
+
sectionId: createSectionId(new Set(sectionBreaks.map((sectionBreak) => sectionBreak.sectionId))),
|
|
3425
|
+
startIndex: dataStream.length - 1
|
|
3426
|
+
});
|
|
3318
3427
|
body.dataStream = dataStream;
|
|
3319
3428
|
body.paragraphs = paragraphs;
|
|
3320
3429
|
body.sectionBreaks = sectionBreaks;
|
|
@@ -3813,6 +3922,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
3813
3922
|
internalDocData = cache;
|
|
3814
3923
|
} else internalDocData = createInternalClipboardDocDataList(documentList);
|
|
3815
3924
|
if (internalDocData) {
|
|
3925
|
+
internalDocData = this._applyCopyDocDataHooks(internalDocData, documentList);
|
|
3816
3926
|
internalJson = createInternalClipboardFragment(internalDocData);
|
|
3817
3927
|
html = embedInternalClipboardFragment(html, internalJson);
|
|
3818
3928
|
}
|
|
@@ -3826,6 +3936,12 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
3826
3936
|
if (index > -1) this._clipboardHooks.splice(index, 1);
|
|
3827
3937
|
});
|
|
3828
3938
|
}
|
|
3939
|
+
_applyCopyDocDataHooks(doc, sourceDocuments) {
|
|
3940
|
+
return this._clipboardHooks.reduce((currentDoc, hook) => {
|
|
3941
|
+
var _hook$onCopyDocData, _hook$onCopyDocData2;
|
|
3942
|
+
return (_hook$onCopyDocData = (_hook$onCopyDocData2 = hook.onCopyDocData) === null || _hook$onCopyDocData2 === void 0 ? void 0 : _hook$onCopyDocData2.call(hook, currentDoc, { sourceDocuments })) !== null && _hook$onCopyDocData !== void 0 ? _hook$onCopyDocData : currentDoc;
|
|
3943
|
+
}, doc);
|
|
3944
|
+
}
|
|
3829
3945
|
_getDocumentBodyInRanges(sliceType, ranges) {
|
|
3830
3946
|
var _docDataModel$getSelf;
|
|
3831
3947
|
const docDataModel = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
@@ -4119,6 +4235,17 @@ const DocPasteCommand = {
|
|
|
4119
4235
|
|
|
4120
4236
|
//#endregion
|
|
4121
4237
|
//#region src/commands/commands/doc-block-move.command.ts
|
|
4238
|
+
const DOC_BLOCK_MOVE_BODY_PATCH_KEYS = [
|
|
4239
|
+
"paragraphs",
|
|
4240
|
+
"sectionBreaks",
|
|
4241
|
+
"tables",
|
|
4242
|
+
"columnGroups",
|
|
4243
|
+
"customBlocks",
|
|
4244
|
+
"blockRanges",
|
|
4245
|
+
"customRanges",
|
|
4246
|
+
"customDecorations",
|
|
4247
|
+
"textRuns"
|
|
4248
|
+
];
|
|
4122
4249
|
const MoveDocBlockCommand = {
|
|
4123
4250
|
id: "doc.command.move-block",
|
|
4124
4251
|
type: CommandType.COMMAND,
|
|
@@ -4142,7 +4269,11 @@ const MoveDocBlockCommand = {
|
|
|
4142
4269
|
previousDocumentData,
|
|
4143
4270
|
result: moveResult
|
|
4144
4271
|
});
|
|
4145
|
-
const actions = buildReplaceDocumentBodyActions(previousDocumentData, nextDocumentData
|
|
4272
|
+
const actions = buildReplaceDocumentBodyActions(previousDocumentData, nextDocumentData, {
|
|
4273
|
+
sourceRange,
|
|
4274
|
+
targetOffset,
|
|
4275
|
+
movedRange
|
|
4276
|
+
});
|
|
4146
4277
|
if (!actions) return false;
|
|
4147
4278
|
const textRanges = [{
|
|
4148
4279
|
startOffset: movedRange.startOffset,
|
|
@@ -4188,23 +4319,121 @@ function buildMoveDocBlockActions(params) {
|
|
|
4188
4319
|
}
|
|
4189
4320
|
};
|
|
4190
4321
|
}
|
|
4191
|
-
function buildReplaceDocumentBodyActions(previousDocumentData, nextDocumentData) {
|
|
4192
|
-
|
|
4322
|
+
function buildReplaceDocumentBodyActions(previousDocumentData, nextDocumentData, move) {
|
|
4323
|
+
JSONX.getInstance();
|
|
4193
4324
|
const previousBody = previousDocumentData.body;
|
|
4194
4325
|
const nextBody = nextDocumentData.body;
|
|
4195
4326
|
if (!previousBody || !nextBody) return null;
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4327
|
+
const rawActions = [];
|
|
4328
|
+
let intermediateDocumentData = Tools.deepClone(previousDocumentData);
|
|
4329
|
+
const moveTextAction = move ? buildMoveBodyTextAction(previousBody, nextBody, move) : null;
|
|
4330
|
+
if (moveTextAction) {
|
|
4331
|
+
rawActions.push(moveTextAction);
|
|
4332
|
+
intermediateDocumentData = JSONX.apply(intermediateDocumentData, moveTextAction);
|
|
4333
|
+
}
|
|
4334
|
+
const residualTextAction = buildSingleBodyTextChangeAction(intermediateDocumentData.body, nextBody);
|
|
4335
|
+
if (residualTextAction) {
|
|
4336
|
+
rawActions.push(residualTextAction);
|
|
4337
|
+
intermediateDocumentData = JSONX.apply(intermediateDocumentData, residualTextAction);
|
|
4338
|
+
}
|
|
4339
|
+
if (!moveTextAction) collectBodyPatchActions(intermediateDocumentData.body, nextBody, rawActions);
|
|
4340
|
+
return rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null);
|
|
4341
|
+
}
|
|
4342
|
+
function buildMoveBodyTextAction(previousBody, nextBody, move) {
|
|
4343
|
+
const dataStreamLength = previousBody.dataStream.length;
|
|
4344
|
+
const startOffset = clamp$1(move.sourceRange.startOffset, 0, dataStreamLength);
|
|
4345
|
+
const endOffset = clamp$1(move.sourceRange.endOffset, startOffset, dataStreamLength);
|
|
4346
|
+
const targetOffset = clamp$1(move.targetOffset, 0, dataStreamLength);
|
|
4347
|
+
const moveLength = endOffset - startOffset;
|
|
4348
|
+
if (moveLength <= 0 || targetOffset >= startOffset && targetOffset <= endOffset) return null;
|
|
4349
|
+
const textX = new TextX();
|
|
4350
|
+
const insertOffset = move.movedRange.startOffset;
|
|
4351
|
+
const insertBody = getBodySliceForTextXAction(nextBody, insertOffset, insertOffset + moveLength, false);
|
|
4352
|
+
if (targetOffset < startOffset) {
|
|
4353
|
+
textX.retain(targetOffset);
|
|
4354
|
+
textX.insert(moveLength, insertBody);
|
|
4355
|
+
textX.retain(startOffset - targetOffset);
|
|
4356
|
+
textX.delete(moveLength);
|
|
4357
|
+
} else {
|
|
4358
|
+
textX.retain(startOffset);
|
|
4359
|
+
textX.delete(moveLength);
|
|
4360
|
+
textX.retain(targetOffset - endOffset);
|
|
4361
|
+
textX.insert(moveLength, insertBody);
|
|
4362
|
+
}
|
|
4363
|
+
return JSONX.getInstance().editOp(textX.serialize(), ["body"]);
|
|
4364
|
+
}
|
|
4365
|
+
function buildSingleBodyTextChangeAction(previousBody, nextBody) {
|
|
4366
|
+
const textChange = getSingleDataStreamChange(previousBody === null || previousBody === void 0 ? void 0 : previousBody.dataStream, nextBody.dataStream);
|
|
4367
|
+
if (!textChange) return null;
|
|
4368
|
+
const textX = new TextX();
|
|
4369
|
+
textX.retain(textChange.start);
|
|
4370
|
+
if (textChange.insertLength > 0) textX.insert(textChange.insertLength, getBodySliceForTextXAction(nextBody, textChange.start, textChange.start + textChange.insertLength, false));
|
|
4371
|
+
if (textChange.deleteLength > 0) textX.delete(textChange.deleteLength);
|
|
4372
|
+
return JSONX.getInstance().editOp(textX.serialize(), ["body"]);
|
|
4373
|
+
}
|
|
4374
|
+
function getSingleDataStreamChange(previousDataStream, nextDataStream) {
|
|
4375
|
+
if (previousDataStream == null || nextDataStream == null || previousDataStream === nextDataStream) return null;
|
|
4376
|
+
let start = 0;
|
|
4377
|
+
while (start < previousDataStream.length && start < nextDataStream.length && previousDataStream[start] === nextDataStream[start]) start++;
|
|
4378
|
+
let previousEnd = previousDataStream.length;
|
|
4379
|
+
let nextEnd = nextDataStream.length;
|
|
4380
|
+
while (previousEnd > start && nextEnd > start && previousDataStream[previousEnd - 1] === nextDataStream[nextEnd - 1]) {
|
|
4381
|
+
previousEnd--;
|
|
4382
|
+
nextEnd--;
|
|
4383
|
+
}
|
|
4384
|
+
return {
|
|
4385
|
+
start,
|
|
4386
|
+
deleteLength: previousEnd - start,
|
|
4387
|
+
insertLength: nextEnd - start
|
|
4388
|
+
};
|
|
4389
|
+
}
|
|
4390
|
+
function collectBodyPatchActions(previousBody, nextBody, actions) {
|
|
4391
|
+
for (const key of DOC_BLOCK_MOVE_BODY_PATCH_KEYS) collectPatchActions(JSONX.getInstance(), ["body", key], previousBody === null || previousBody === void 0 ? void 0 : previousBody[key], nextBody[key], actions);
|
|
4392
|
+
}
|
|
4393
|
+
function collectPatchActions(jsonX, path, oldValue, newValue, actions) {
|
|
4394
|
+
if (isEmptyArrayEquivalent$1(oldValue, newValue)) return;
|
|
4395
|
+
if (Tools.diffValue(oldValue, newValue)) return;
|
|
4396
|
+
if (oldValue == null) {
|
|
4397
|
+
actions.push(jsonX.insertOp(path, newValue));
|
|
4398
|
+
return;
|
|
4399
|
+
}
|
|
4400
|
+
if (newValue == null) {
|
|
4401
|
+
actions.push(jsonX.removeOp(path, oldValue));
|
|
4402
|
+
return;
|
|
4403
|
+
}
|
|
4404
|
+
if (Array.isArray(oldValue) && Array.isArray(newValue)) {
|
|
4405
|
+
collectArrayPatchActions(jsonX, path, oldValue, newValue, actions);
|
|
4406
|
+
return;
|
|
4407
|
+
}
|
|
4408
|
+
if (isPlainObject$1(oldValue) && isPlainObject$1(newValue)) {
|
|
4409
|
+
(/* @__PURE__ */ new Set([...Object.keys(oldValue), ...Object.keys(newValue)])).forEach((key) => {
|
|
4410
|
+
collectPatchActions(jsonX, [...path, key], oldValue[key], newValue[key], actions);
|
|
4411
|
+
});
|
|
4412
|
+
return;
|
|
4413
|
+
}
|
|
4414
|
+
actions.push(jsonX.replaceOp(path, oldValue, newValue));
|
|
4415
|
+
}
|
|
4416
|
+
function collectArrayPatchActions(jsonX, path, oldItems, newItems, actions) {
|
|
4417
|
+
if (oldItems.length === newItems.length) {
|
|
4418
|
+
oldItems.forEach((item, index) => collectPatchActions(jsonX, [...path, index], item, newItems[index], actions));
|
|
4419
|
+
return;
|
|
4420
|
+
}
|
|
4421
|
+
let prefix = 0;
|
|
4422
|
+
while (prefix < oldItems.length && prefix < newItems.length && Tools.diffValue(oldItems[prefix], newItems[prefix])) prefix++;
|
|
4423
|
+
let oldSuffix = oldItems.length - 1;
|
|
4424
|
+
let newSuffix = newItems.length - 1;
|
|
4425
|
+
while (oldSuffix >= prefix && newSuffix >= prefix && Tools.diffValue(oldItems[oldSuffix], newItems[newSuffix])) {
|
|
4426
|
+
oldSuffix--;
|
|
4427
|
+
newSuffix--;
|
|
4428
|
+
}
|
|
4429
|
+
for (let index = oldSuffix; index >= prefix; index--) actions.push(jsonX.removeOp([...path, index], oldItems[index]));
|
|
4430
|
+
for (let index = prefix; index <= newSuffix; index++) actions.push(jsonX.insertOp([...path, index], newItems[index]));
|
|
4431
|
+
}
|
|
4432
|
+
function isPlainObject$1(value) {
|
|
4433
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
4434
|
+
}
|
|
4435
|
+
function isEmptyArrayEquivalent$1(oldValue, newValue) {
|
|
4436
|
+
return oldValue == null && Array.isArray(newValue) && newValue.length === 0 || newValue == null && Array.isArray(oldValue) && oldValue.length === 0;
|
|
4208
4437
|
}
|
|
4209
4438
|
function remapBodyIndexesAfterMove(body, startOffset, endOffset, targetOffset, insertOffset, moveLength) {
|
|
4210
4439
|
var _body$paragraphs, _body$sectionBreaks, _body$customBlocks, _body$tables, _body$columnGroups, _body$blockRanges, _body$customRanges, _body$customDecoratio, _body$textRuns;
|
|
@@ -4289,6 +4518,7 @@ const HorizontalLineCommand = {
|
|
|
4289
4518
|
width: 1,
|
|
4290
4519
|
dashStyle: DashStyleType.SOLID
|
|
4291
4520
|
},
|
|
4521
|
+
insertionMode: params === null || params === void 0 ? void 0 : params.insertionMode,
|
|
4292
4522
|
textRange: params === null || params === void 0 ? void 0 : params.insertRange
|
|
4293
4523
|
});
|
|
4294
4524
|
}
|
|
@@ -4305,10 +4535,13 @@ const InsertHorizontalLineBellowCommand = {
|
|
|
4305
4535
|
} catch {
|
|
4306
4536
|
contentInsertRange = null;
|
|
4307
4537
|
}
|
|
4308
|
-
if (contentInsertRange) return commandService.syncExecuteCommand(HorizontalLineCommand.id, {
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4538
|
+
if (contentInsertRange) return commandService.syncExecuteCommand(HorizontalLineCommand.id, {
|
|
4539
|
+
insertionMode: "insert-gap",
|
|
4540
|
+
insertRange: {
|
|
4541
|
+
startOffset: contentInsertRange.startOffset,
|
|
4542
|
+
endOffset: contentInsertRange.endOffset
|
|
4543
|
+
}
|
|
4544
|
+
});
|
|
4312
4545
|
const paragraph = getCurrentParagraph(accessor);
|
|
4313
4546
|
if (!paragraph) return false;
|
|
4314
4547
|
return commandService.syncExecuteCommand(HorizontalLineCommand.id, { insertRange: {
|
|
@@ -4384,7 +4617,7 @@ function getTextRangesByParagraphs(body, startOffset, endOffset) {
|
|
|
4384
4617
|
return ranges;
|
|
4385
4618
|
}
|
|
4386
4619
|
function getScopedSelectAllRange(body, activeRange) {
|
|
4387
|
-
var _body$tables2, _body$customBlocks, _body$blockRanges, _body$
|
|
4620
|
+
var _body$tables2, _body$customBlocks, _body$blockRanges, _body$tables3;
|
|
4388
4621
|
const startOffset = activeRange.startOffset;
|
|
4389
4622
|
const endOffset = activeRange.endOffset;
|
|
4390
4623
|
if (startOffset == null || endOffset == null) return null;
|
|
@@ -4402,7 +4635,7 @@ function getScopedSelectAllRange(body, activeRange) {
|
|
|
4402
4635
|
rangeType: DOC_RANGE_TYPE.TEXT,
|
|
4403
4636
|
startOffset: blockRange.startIndex + 1
|
|
4404
4637
|
}];
|
|
4405
|
-
const paragraphRange = clampParagraphRangeByTables(getParagraphRangeAtOffset(
|
|
4638
|
+
const paragraphRange = clampParagraphRangeByTables(getParagraphRangeAtOffset(body, startOffset), (_body$tables3 = body.tables) !== null && _body$tables3 !== void 0 ? _body$tables3 : [], startOffset);
|
|
4406
4639
|
return paragraphRange ? [{
|
|
4407
4640
|
...paragraphRange,
|
|
4408
4641
|
rangeType: DOC_RANGE_TYPE.TEXT
|
|
@@ -4422,11 +4655,13 @@ function getTableRectRange(table) {
|
|
|
4422
4655
|
rangeType: DOC_RANGE_TYPE.RECT
|
|
4423
4656
|
};
|
|
4424
4657
|
}
|
|
4425
|
-
function getParagraphRangeAtOffset(
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4658
|
+
function getParagraphRangeAtOffset(body, offset) {
|
|
4659
|
+
var _body$paragraphs2;
|
|
4660
|
+
const sortedParagraphs = [...(_body$paragraphs2 = body.paragraphs) !== null && _body$paragraphs2 !== void 0 ? _body$paragraphs2 : []].sort((left, right) => left.startIndex - right.startIndex);
|
|
4661
|
+
const paragraphStartOffsets = getParagraphContentStartOffsets(body);
|
|
4662
|
+
for (const paragraph of sortedParagraphs) {
|
|
4663
|
+
var _paragraphStartOffset;
|
|
4664
|
+
const startOffset = (_paragraphStartOffset = paragraphStartOffsets.get(paragraph.startIndex)) !== null && _paragraphStartOffset !== void 0 ? _paragraphStartOffset : 0;
|
|
4430
4665
|
if (startOffset <= offset && offset <= paragraph.startIndex) return {
|
|
4431
4666
|
endOffset: paragraph.startIndex,
|
|
4432
4667
|
startOffset
|
|
@@ -4971,47 +5206,55 @@ const ReplaceSnapshotCommand = {
|
|
|
4971
5206
|
}
|
|
4972
5207
|
};
|
|
4973
5208
|
if (options) doMutation.params.options = options;
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
}
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
const actions = jsonX.replaceOp(["headers"], prevHeaders, headers);
|
|
4994
|
-
if (actions != null) rawActions.push(actions);
|
|
4995
|
-
}
|
|
4996
|
-
if (!Tools.diffValue(lists, prevLists)) {
|
|
4997
|
-
const actions = jsonX.replaceOp(["lists"], prevLists, lists);
|
|
4998
|
-
if (actions != null) rawActions.push(actions);
|
|
4999
|
-
}
|
|
5000
|
-
if (!Tools.diffValue(drawings, prevDrawings)) {
|
|
5001
|
-
const actions = jsonX.replaceOp(["drawings"], prevDrawings, drawings);
|
|
5002
|
-
if (actions != null) rawActions.push(actions);
|
|
5003
|
-
}
|
|
5004
|
-
if (!Tools.diffValue(drawingsOrder, prevDrawingsOrder)) {
|
|
5005
|
-
const actions = jsonX.replaceOp(["drawingsOrder"], prevDrawingsOrder, drawingsOrder);
|
|
5006
|
-
if (actions != null) rawActions.push(actions);
|
|
5007
|
-
}
|
|
5008
|
-
doMutation.params.actions = rawActions.reduce((acc, cur) => {
|
|
5009
|
-
return JSONX.compose(acc, cur);
|
|
5010
|
-
}, null);
|
|
5209
|
+
doMutation.params.actions = buildReplaceSnapshotActions({
|
|
5210
|
+
body: prevBody,
|
|
5211
|
+
documentStyle: prevDocumentStyle,
|
|
5212
|
+
tableSource: prevTableSource,
|
|
5213
|
+
footers: prevFooters,
|
|
5214
|
+
headers: prevHeaders,
|
|
5215
|
+
lists: prevLists,
|
|
5216
|
+
drawings: prevDrawings,
|
|
5217
|
+
drawingsOrder: prevDrawingsOrder
|
|
5218
|
+
}, {
|
|
5219
|
+
body,
|
|
5220
|
+
documentStyle,
|
|
5221
|
+
tableSource,
|
|
5222
|
+
footers,
|
|
5223
|
+
headers,
|
|
5224
|
+
lists,
|
|
5225
|
+
drawings,
|
|
5226
|
+
drawingsOrder
|
|
5227
|
+
});
|
|
5011
5228
|
const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
5012
5229
|
return Boolean(result);
|
|
5013
5230
|
}
|
|
5014
5231
|
};
|
|
5232
|
+
function buildReplaceSnapshotActions(previousSnapshot, snapshot) {
|
|
5233
|
+
const jsonX = JSONX.getInstance();
|
|
5234
|
+
const rawActions = [];
|
|
5235
|
+
const bodyAction = buildReplaceSnapshotBodyAction(previousSnapshot.body, snapshot.body);
|
|
5236
|
+
if (bodyAction) rawActions.push(bodyAction);
|
|
5237
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["documentStyle"], previousSnapshot.documentStyle, snapshot.documentStyle);
|
|
5238
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["tableSource"], previousSnapshot.tableSource, snapshot.tableSource);
|
|
5239
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["footers"], previousSnapshot.footers, snapshot.footers);
|
|
5240
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["headers"], previousSnapshot.headers, snapshot.headers);
|
|
5241
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["lists"], previousSnapshot.lists, snapshot.lists);
|
|
5242
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["drawings"], previousSnapshot.drawings, snapshot.drawings);
|
|
5243
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["drawingsOrder"], previousSnapshot.drawingsOrder, snapshot.drawingsOrder);
|
|
5244
|
+
return rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null);
|
|
5245
|
+
}
|
|
5246
|
+
function buildReplaceSnapshotBodyAction(previousBody, body) {
|
|
5247
|
+
if (!previousBody || !body || Tools.diffValue(previousBody, body)) return null;
|
|
5248
|
+
const textX = new TextX();
|
|
5249
|
+
if (previousBody.dataStream.length > 0) textX.delete(previousBody.dataStream.length);
|
|
5250
|
+
if (body.dataStream.length > 0) textX.insert(body.dataStream.length, body);
|
|
5251
|
+
return JSONX.getInstance().editOp(textX.serialize(), ["body"]);
|
|
5252
|
+
}
|
|
5253
|
+
function collectTopLevelReplaceAction(jsonX, rawActions, path, previousValue, value) {
|
|
5254
|
+
if (Tools.diffValue(previousValue, value)) return;
|
|
5255
|
+
const action = jsonX.replaceOp(path, previousValue, value);
|
|
5256
|
+
if (action != null) rawActions.push(action);
|
|
5257
|
+
}
|
|
5015
5258
|
/**
|
|
5016
5259
|
* @deprecated please use ReplaceSnapshotCommand instead.
|
|
5017
5260
|
*/
|
|
@@ -5489,7 +5732,7 @@ const QuickListCommand = {
|
|
|
5489
5732
|
return Boolean(result);
|
|
5490
5733
|
}
|
|
5491
5734
|
};
|
|
5492
|
-
function insertList(accessor, listType) {
|
|
5735
|
+
function insertList(accessor, listType, trigger) {
|
|
5493
5736
|
var _contentInsertRange$s, _contentInsertRange$e, _sourceParagraph$para;
|
|
5494
5737
|
const commandService = accessor.get(ICommandService);
|
|
5495
5738
|
const docDataModel = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
@@ -5537,7 +5780,8 @@ function insertList(accessor, listType) {
|
|
|
5537
5780
|
endOffset: insertOffset,
|
|
5538
5781
|
collapsed: true
|
|
5539
5782
|
}],
|
|
5540
|
-
isEditing: false
|
|
5783
|
+
isEditing: false,
|
|
5784
|
+
trigger
|
|
5541
5785
|
}
|
|
5542
5786
|
};
|
|
5543
5787
|
const jsonX = JSONX.getInstance();
|
|
@@ -5550,21 +5794,21 @@ const InsertBulletListBellowCommand = {
|
|
|
5550
5794
|
id: "doc.command.insert-bullet-list-bellow",
|
|
5551
5795
|
type: CommandType.COMMAND,
|
|
5552
5796
|
handler: (accessor) => {
|
|
5553
|
-
return insertList(accessor, PresetListType.BULLET_LIST);
|
|
5797
|
+
return insertList(accessor, PresetListType.BULLET_LIST, InsertBulletListBellowCommand.id);
|
|
5554
5798
|
}
|
|
5555
5799
|
};
|
|
5556
5800
|
const InsertOrderListBellowCommand = {
|
|
5557
5801
|
id: "doc.command.insert-order-list-bellow",
|
|
5558
5802
|
type: CommandType.COMMAND,
|
|
5559
5803
|
handler: (accessor) => {
|
|
5560
|
-
return insertList(accessor, PresetListType.ORDER_LIST);
|
|
5804
|
+
return insertList(accessor, PresetListType.ORDER_LIST, InsertOrderListBellowCommand.id);
|
|
5561
5805
|
}
|
|
5562
5806
|
};
|
|
5563
5807
|
const InsertCheckListBellowCommand = {
|
|
5564
5808
|
id: "doc.command.insert-check-list-bellow",
|
|
5565
5809
|
type: CommandType.COMMAND,
|
|
5566
5810
|
handler: (accessor) => {
|
|
5567
|
-
return insertList(accessor, PresetListType.CHECK_LIST);
|
|
5811
|
+
return insertList(accessor, PresetListType.CHECK_LIST, InsertCheckListBellowCommand.id);
|
|
5568
5812
|
}
|
|
5569
5813
|
};
|
|
5570
5814
|
|
|
@@ -5733,7 +5977,7 @@ const SetParagraphNamedStyleCommand = {
|
|
|
5733
5977
|
const unitId = doc.getUnitId();
|
|
5734
5978
|
const selectionService = accessor.get(DocSelectionManagerService);
|
|
5735
5979
|
const contentInsertRange = params.textRanges ? null : consumeContentInsertRange(accessor, unitId);
|
|
5736
|
-
if (contentInsertRange) return insertNamedStyleParagraph(accessor, doc, params.value, contentInsertRange.startOffset, contentInsertRange.endOffset);
|
|
5980
|
+
if (contentInsertRange) return insertNamedStyleParagraph(accessor, doc, params.value, contentInsertRange.startOffset, contentInsertRange.endOffset, contentInsertRange.segmentId);
|
|
5737
5981
|
const selections = (_params$textRanges = params.textRanges) !== null && _params$textRanges !== void 0 ? _params$textRanges : selectionService.getTextRanges({
|
|
5738
5982
|
unitId,
|
|
5739
5983
|
subUnitId: unitId
|
|
@@ -5770,13 +6014,14 @@ const SetParagraphNamedStyleCommand = {
|
|
|
5770
6014
|
return Boolean(result);
|
|
5771
6015
|
}
|
|
5772
6016
|
};
|
|
5773
|
-
function insertNamedStyleParagraph(accessor, doc, namedStyleType, startOffset, endOffset) {
|
|
6017
|
+
function insertNamedStyleParagraph(accessor, doc, namedStyleType, startOffset, endOffset, segmentId = "") {
|
|
5774
6018
|
const textX = BuildTextUtils.selection.replace({
|
|
5775
6019
|
doc,
|
|
5776
6020
|
selection: {
|
|
5777
6021
|
startOffset,
|
|
5778
6022
|
endOffset,
|
|
5779
|
-
collapsed: startOffset === endOffset
|
|
6023
|
+
collapsed: startOffset === endOffset,
|
|
6024
|
+
segmentId
|
|
5780
6025
|
},
|
|
5781
6026
|
body: {
|
|
5782
6027
|
dataStream: "\r",
|
|
@@ -5793,16 +6038,22 @@ function insertNamedStyleParagraph(accessor, doc, namedStyleType, startOffset, e
|
|
|
5793
6038
|
if (!textX) return false;
|
|
5794
6039
|
const jsonX = JSONX.getInstance();
|
|
5795
6040
|
const commandService = accessor.get(ICommandService);
|
|
5796
|
-
|
|
5797
|
-
actions: jsonX.editOp(textX.serialize(), getRichTextEditPath(doc)),
|
|
6041
|
+
const success = Boolean(commandService.syncExecuteCommand(RichTextEditingMutation.id, {
|
|
6042
|
+
actions: jsonX.editOp(textX.serialize(), getRichTextEditPath(doc, segmentId)),
|
|
5798
6043
|
isEditing: false,
|
|
5799
6044
|
textRanges: [{
|
|
5800
6045
|
startOffset,
|
|
5801
6046
|
endOffset: startOffset,
|
|
5802
6047
|
collapsed: true
|
|
5803
6048
|
}],
|
|
6049
|
+
segmentId,
|
|
5804
6050
|
unitId: doc.getUnitId()
|
|
5805
6051
|
}));
|
|
6052
|
+
if (success) accessor.get(DocSelectionManagerService).replaceTextRanges([{
|
|
6053
|
+
startOffset,
|
|
6054
|
+
endOffset: startOffset
|
|
6055
|
+
}], false);
|
|
6056
|
+
return success;
|
|
5806
6057
|
}
|
|
5807
6058
|
const QuickHeadingCommand = {
|
|
5808
6059
|
id: "doc.command.quick-heading",
|
|
@@ -5927,6 +6178,88 @@ const SubtitleHeadingCommand = {
|
|
|
5927
6178
|
}
|
|
5928
6179
|
};
|
|
5929
6180
|
|
|
6181
|
+
//#endregion
|
|
6182
|
+
//#region src/services/doc-embed-integration.service.ts
|
|
6183
|
+
const DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
|
|
6184
|
+
var EmbedInteractionBoundaryService = class {
|
|
6185
|
+
constructor() {
|
|
6186
|
+
_defineProperty(this, "_roots", /* @__PURE__ */ new Map());
|
|
6187
|
+
}
|
|
6188
|
+
registerOwnedElement(embedId, element) {
|
|
6189
|
+
element.setAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, embedId);
|
|
6190
|
+
element.querySelectorAll("*").forEach((child) => child.setAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, embedId));
|
|
6191
|
+
let roots = this._roots.get(embedId);
|
|
6192
|
+
if (!roots) {
|
|
6193
|
+
roots = /* @__PURE__ */ new Set();
|
|
6194
|
+
this._roots.set(embedId, roots);
|
|
6195
|
+
}
|
|
6196
|
+
roots.add(element);
|
|
6197
|
+
return toDisposable(() => {
|
|
6198
|
+
roots === null || roots === void 0 || roots.delete(element);
|
|
6199
|
+
element.removeAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE);
|
|
6200
|
+
element.querySelectorAll("*").forEach((child) => child.removeAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE));
|
|
6201
|
+
});
|
|
6202
|
+
}
|
|
6203
|
+
contains(embedId, target) {
|
|
6204
|
+
var _this$_roots$get;
|
|
6205
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
6206
|
+
if (!embedId) return [...this._roots.values()].some((roots) => [...roots].some((root) => root.contains(target)));
|
|
6207
|
+
return ((_this$_roots$get = this._roots.get(embedId)) === null || _this$_roots$get === void 0 ? void 0 : _this$_roots$get.has(target)) === true || this._roots.get(embedId) != null && [...this._roots.get(embedId)].some((root) => root.contains(target));
|
|
6208
|
+
}
|
|
6209
|
+
hasRecentInteraction() {
|
|
6210
|
+
return false;
|
|
6211
|
+
}
|
|
6212
|
+
hasRecentInteractionFor() {
|
|
6213
|
+
return false;
|
|
6214
|
+
}
|
|
6215
|
+
};
|
|
6216
|
+
const IDocEmbedInteractionBoundaryService = EmbedInteractionBoundaryService;
|
|
6217
|
+
var EmbedRuntimeFocusCoordinator = class {
|
|
6218
|
+
constructor() {
|
|
6219
|
+
_defineProperty(this, "_leases", /* @__PURE__ */ new Set());
|
|
6220
|
+
_defineProperty(this, "_elements", /* @__PURE__ */ new Map());
|
|
6221
|
+
_defineProperty(this, "runtimeSessionChanged$", new Subject());
|
|
6222
|
+
}
|
|
6223
|
+
acquireLease(options) {
|
|
6224
|
+
this._leases.add(options);
|
|
6225
|
+
this.runtimeSessionChanged$.next();
|
|
6226
|
+
return toDisposable(() => {
|
|
6227
|
+
this._leases.delete(options);
|
|
6228
|
+
this.runtimeSessionChanged$.next();
|
|
6229
|
+
});
|
|
6230
|
+
}
|
|
6231
|
+
registerElement(options) {
|
|
6232
|
+
options.element.setAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, options.embedId);
|
|
6233
|
+
let elements = this._elements.get(options.embedId);
|
|
6234
|
+
if (!elements) {
|
|
6235
|
+
elements = /* @__PURE__ */ new Set();
|
|
6236
|
+
this._elements.set(options.embedId, elements);
|
|
6237
|
+
}
|
|
6238
|
+
elements.add(options.element);
|
|
6239
|
+
return toDisposable(() => {
|
|
6240
|
+
elements === null || elements === void 0 || elements.delete(options.element);
|
|
6241
|
+
options.element.removeAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE);
|
|
6242
|
+
});
|
|
6243
|
+
}
|
|
6244
|
+
registerRuntimeScope(_options) {
|
|
6245
|
+
return toDisposable(() => {});
|
|
6246
|
+
}
|
|
6247
|
+
isChildUnitRuntimeEvent(_unitId, target) {
|
|
6248
|
+
return target instanceof HTMLElement && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
|
|
6249
|
+
}
|
|
6250
|
+
isChildUnitInActiveSession(unitId) {
|
|
6251
|
+
return [...this._leases].some((lease) => lease.role !== "runtime" && lease.childUnitId === unitId);
|
|
6252
|
+
}
|
|
6253
|
+
shouldSuppressHostInteraction(unitId, target) {
|
|
6254
|
+
if (this.isChildUnitRuntimeEvent(unitId, target)) return false;
|
|
6255
|
+
return [...this._leases].some((lease) => {
|
|
6256
|
+
if (lease.role === "runtime" || lease.childUnitId === unitId) return false;
|
|
6257
|
+
return lease.hostUnitId === unitId || !lease.hostUnitId && !lease.childUnitId;
|
|
6258
|
+
});
|
|
6259
|
+
}
|
|
6260
|
+
};
|
|
6261
|
+
const IDocEmbedRuntimeFocusCoordinator = EmbedRuntimeFocusCoordinator;
|
|
6262
|
+
|
|
5930
6263
|
//#endregion
|
|
5931
6264
|
//#region src/services/selection/convert-text-range.ts
|
|
5932
6265
|
let NodePositionType = /* @__PURE__ */ function(NodePositionType) {
|
|
@@ -6078,7 +6411,10 @@ var NodePositionConvertToCursor = class {
|
|
|
6078
6411
|
const isStartBack = start.glyph === start_sp && isFirst ? start.isBack : true;
|
|
6079
6412
|
const isEndBack = end.glyph === end_sp && isLast ? end.isBack : false;
|
|
6080
6413
|
const collapsed = start === end;
|
|
6081
|
-
const
|
|
6414
|
+
const rawAnchorGlyph = isStartBack ? preGlyph !== null && preGlyph !== void 0 ? preGlyph : firstGlyph : firstGlyph;
|
|
6415
|
+
const anchorGlyph = this._getCaretGlyph(rawAnchorGlyph, glyphGroup, start_sp);
|
|
6416
|
+
const selectedGlyphs = glyphGroup.slice(start_sp, end_sp + 1);
|
|
6417
|
+
const isSelectionOnlyNonInlineEmbedBlock = !collapsed && selectedGlyphs.length > 0 && selectedGlyphs.every((glyph) => this._isNonInlineEmbedCustomBlockGlyph(glyph));
|
|
6082
6418
|
const borderBoxStartY = startY;
|
|
6083
6419
|
const borderBoxEndY = contentHeight == null ? startY + lineHeight - marginTop - marginBottom : startY + paddingTop + contentHeight + paddingBottom;
|
|
6084
6420
|
if (start_sp === 0 && end_sp === glyphGroup.length - 1) {
|
|
@@ -6111,8 +6447,8 @@ var NodePositionConvertToCursor = class {
|
|
|
6111
6447
|
}
|
|
6112
6448
|
const clippedBorderBoxPosition = clipPositionToHorizontalRange(borderBoxPosition, this._horizontalClip);
|
|
6113
6449
|
const clippedContentBoxPosition = clipPositionToHorizontalRange(contentBoxPosition, this._horizontalClip);
|
|
6114
|
-
if (clippedBorderBoxPosition) borderBoxPointGroup.push(pushToPoints(clippedBorderBoxPosition));
|
|
6115
|
-
if (clippedContentBoxPosition) contentBoxPointGroup.push(pushToPoints(clippedContentBoxPosition));
|
|
6450
|
+
if (clippedBorderBoxPosition && !isSelectionOnlyNonInlineEmbedBlock) borderBoxPointGroup.push(pushToPoints(clippedBorderBoxPosition));
|
|
6451
|
+
if (clippedContentBoxPosition && !isSelectionOnlyNonInlineEmbedBlock) contentBoxPointGroup.push(pushToPoints(clippedContentBoxPosition));
|
|
6116
6452
|
cursorList.push({
|
|
6117
6453
|
startOffset: isStartBack ? startOffset : startOffset + firstGlyph.count,
|
|
6118
6454
|
endOffset: isEndBack ? endOffset : endOffset + lastGlyph.count,
|
|
@@ -6125,6 +6461,26 @@ var NodePositionConvertToCursor = class {
|
|
|
6125
6461
|
cursorList
|
|
6126
6462
|
};
|
|
6127
6463
|
}
|
|
6464
|
+
_getCaretGlyph(glyph, glyphGroup, glyphIndex) {
|
|
6465
|
+
var _this$_findTextLikeGl;
|
|
6466
|
+
if (!glyph || !this._isNonInlineEmbedCustomBlockGlyph(glyph)) return glyph;
|
|
6467
|
+
const neighbor = (_this$_findTextLikeGl = this._findTextLikeGlyph(glyphGroup, glyphIndex - 1, -1)) !== null && _this$_findTextLikeGl !== void 0 ? _this$_findTextLikeGl : this._findTextLikeGlyph(glyphGroup, glyphIndex + 1, 1);
|
|
6468
|
+
return neighbor !== null && neighbor !== void 0 ? neighbor : {
|
|
6469
|
+
...glyph,
|
|
6470
|
+
bBox: getDefaultCaretBoundingBox(glyph)
|
|
6471
|
+
};
|
|
6472
|
+
}
|
|
6473
|
+
_findTextLikeGlyph(glyphGroup, startIndex, step) {
|
|
6474
|
+
for (let index = startIndex; index >= 0 && index < glyphGroup.length; index += step) {
|
|
6475
|
+
const glyph = glyphGroup[index];
|
|
6476
|
+
if (!this._isNonInlineEmbedCustomBlockGlyph(glyph)) return glyph;
|
|
6477
|
+
}
|
|
6478
|
+
}
|
|
6479
|
+
_isNonInlineEmbedCustomBlockGlyph(glyph) {
|
|
6480
|
+
var _this$_docSkeleton$ge, _this$_docSkeleton, _this$_docSkeleton$ge2, _this$_docSkeleton$ge3, _this$_docSkeleton$ge4, _this$_docSkeleton$ge5;
|
|
6481
|
+
if (!(glyph === null || glyph === void 0 ? void 0 : glyph.drawingId) || glyph.streamType !== DataStreamTreeTokenType.CUSTOM_BLOCK) return false;
|
|
6482
|
+
return !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]);
|
|
6483
|
+
}
|
|
6128
6484
|
_isValidPosition(startOrigin, endOrigin) {
|
|
6129
6485
|
const { segmentPage: startPage, pageType: startPageType } = startOrigin;
|
|
6130
6486
|
const { segmentPage: endPage, pageType: endPageType } = endOrigin;
|
|
@@ -6370,6 +6726,19 @@ function getCellPageFromSegmentPath(skeletonData, rootPage, path) {
|
|
|
6370
6726
|
}
|
|
6371
6727
|
return null;
|
|
6372
6728
|
}
|
|
6729
|
+
function getDefaultCaretBoundingBox(glyph) {
|
|
6730
|
+
const fontSize = getGlyphFontSize(glyph);
|
|
6731
|
+
return {
|
|
6732
|
+
...glyph.bBox,
|
|
6733
|
+
ba: fontSize,
|
|
6734
|
+
bd: Math.max(2, Math.ceil(fontSize * .25))
|
|
6735
|
+
};
|
|
6736
|
+
}
|
|
6737
|
+
function getGlyphFontSize(glyph) {
|
|
6738
|
+
var _ref, _glyph$fontStyle$orig, _glyph$fontStyle, _glyph$fontStyle2, _glyph$ts;
|
|
6739
|
+
const fontSize = (_ref = (_glyph$fontStyle$orig = (_glyph$fontStyle = glyph.fontStyle) === null || _glyph$fontStyle === void 0 ? void 0 : _glyph$fontStyle.originFontSize) !== null && _glyph$fontStyle$orig !== void 0 ? _glyph$fontStyle$orig : (_glyph$fontStyle2 = glyph.fontStyle) === null || _glyph$fontStyle2 === void 0 ? void 0 : _glyph$fontStyle2.fontSize) !== null && _ref !== void 0 ? _ref : (_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.fs;
|
|
6740
|
+
return typeof fontSize === "number" && Number.isFinite(fontSize) && fontSize > 0 ? fontSize : 14;
|
|
6741
|
+
}
|
|
6373
6742
|
function getDocumentUnitId$1(docSkeleton) {
|
|
6374
6743
|
var _viewModel$getDataMod, _viewModel$getDataMod2, _viewModel$getDataMod3, _viewModel$getDataMod4;
|
|
6375
6744
|
const viewModel = docSkeleton.getViewModel();
|
|
@@ -7520,18 +7889,22 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
7520
7889
|
return this._onPointerEvent;
|
|
7521
7890
|
}
|
|
7522
7891
|
get isFocusing() {
|
|
7523
|
-
return this._input ===
|
|
7892
|
+
return this._input === this._getOwnerDocument().activeElement;
|
|
7524
7893
|
}
|
|
7525
7894
|
get canFocusing() {
|
|
7526
|
-
|
|
7895
|
+
const ownerDocument = this._getOwnerDocument();
|
|
7896
|
+
const activeElement = ownerDocument.activeElement;
|
|
7897
|
+
return !this._shouldPreserveExternalFocus() && (this.isFocusing || activeElement === ownerDocument.body || activeElement === null || activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement));
|
|
7527
7898
|
}
|
|
7528
|
-
constructor(_context, _layoutService, _logService, _univerInstanceService, _docSkeletonManagerService) {
|
|
7899
|
+
constructor(_context, _layoutService, _logService, _univerInstanceService, _docSkeletonManagerService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
7529
7900
|
super();
|
|
7530
7901
|
this._context = _context;
|
|
7531
7902
|
this._layoutService = _layoutService;
|
|
7532
7903
|
this._logService = _logService;
|
|
7533
7904
|
this._univerInstanceService = _univerInstanceService;
|
|
7534
7905
|
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
7906
|
+
this._embedInteractionBoundaryService = _embedInteractionBoundaryService;
|
|
7907
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
7535
7908
|
_defineProperty(this, "_onInputBefore$", new Subject());
|
|
7536
7909
|
_defineProperty(this, "onInputBefore$", this._onInputBefore$.asObservable());
|
|
7537
7910
|
_defineProperty(this, "_onKeydown$", new Subject());
|
|
@@ -7569,6 +7942,11 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
7569
7942
|
_defineProperty(this, "_focusNodePosition", null);
|
|
7570
7943
|
_defineProperty(this, "_currentSegmentId", "");
|
|
7571
7944
|
_defineProperty(this, "_currentSegmentPage", -1);
|
|
7945
|
+
_defineProperty(this, "_segmentContext$", new BehaviorSubject({
|
|
7946
|
+
segmentId: "",
|
|
7947
|
+
segmentPage: -1
|
|
7948
|
+
}));
|
|
7949
|
+
_defineProperty(this, "segmentContext$", this._segmentContext$.asObservable());
|
|
7572
7950
|
_defineProperty(this, "_selectionStyle", NORMAL_TEXT_SELECTION_PLUGIN_STYLE);
|
|
7573
7951
|
_defineProperty(this, "_onPointerEvent", false);
|
|
7574
7952
|
_defineProperty(this, "_viewPortObserverMap", /* @__PURE__ */ new Map());
|
|
@@ -7591,13 +7969,23 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
7591
7969
|
return this._context.scene.getViewports()[0];
|
|
7592
7970
|
}
|
|
7593
7971
|
setSegment(id) {
|
|
7972
|
+
if (this._currentSegmentId === id) return;
|
|
7594
7973
|
this._currentSegmentId = id;
|
|
7974
|
+
this._segmentContext$.next({
|
|
7975
|
+
segmentId: id,
|
|
7976
|
+
segmentPage: this._currentSegmentPage
|
|
7977
|
+
});
|
|
7595
7978
|
}
|
|
7596
7979
|
getSegment() {
|
|
7597
7980
|
return this._currentSegmentId;
|
|
7598
7981
|
}
|
|
7599
7982
|
setSegmentPage(pageIndex) {
|
|
7983
|
+
if (this._currentSegmentPage === pageIndex) return;
|
|
7600
7984
|
this._currentSegmentPage = pageIndex;
|
|
7985
|
+
this._segmentContext$.next({
|
|
7986
|
+
segmentId: this._currentSegmentId,
|
|
7987
|
+
segmentPage: pageIndex
|
|
7988
|
+
});
|
|
7601
7989
|
}
|
|
7602
7990
|
getSegmentPage() {
|
|
7603
7991
|
return this._currentSegmentPage;
|
|
@@ -7672,14 +8060,11 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
7672
8060
|
sync() {
|
|
7673
8061
|
this._updateInputPosition();
|
|
7674
8062
|
}
|
|
7675
|
-
/**
|
|
7676
|
-
* @deprecated
|
|
7677
|
-
*/
|
|
7678
8063
|
activate(x, y, force = false) {
|
|
7679
8064
|
this._ensureHostContainer();
|
|
7680
8065
|
let left = x;
|
|
7681
8066
|
let top = y;
|
|
7682
|
-
const fixedContainer = this._container.
|
|
8067
|
+
const fixedContainer = this._container.offsetParent;
|
|
7683
8068
|
if (fixedContainer) {
|
|
7684
8069
|
const rect = fixedContainer.getBoundingClientRect();
|
|
7685
8070
|
left -= rect.left;
|
|
@@ -7688,12 +8073,13 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
7688
8073
|
this._container.style.left = `${left}px`;
|
|
7689
8074
|
this._container.style.top = `${top}px`;
|
|
7690
8075
|
this._container.style.zIndex = "1000";
|
|
7691
|
-
if (this.
|
|
8076
|
+
if (force && !this._shouldPreserveExternalFocus() || !force && this.canFocusing) this.focus();
|
|
7692
8077
|
}
|
|
7693
8078
|
hasFocus() {
|
|
7694
|
-
return
|
|
8079
|
+
return this._getOwnerDocument().activeElement === this._input;
|
|
7695
8080
|
}
|
|
7696
8081
|
focus() {
|
|
8082
|
+
if (!this._input.hasAttribute("tabindex")) this._input.tabIndex = -1;
|
|
7697
8083
|
this._input.focus();
|
|
7698
8084
|
}
|
|
7699
8085
|
blur() {
|
|
@@ -7935,6 +8321,10 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
7935
8321
|
}
|
|
7936
8322
|
if (this._container.parentElement !== document.body) document.body.appendChild(this._container);
|
|
7937
8323
|
}
|
|
8324
|
+
_getOwnerDocument() {
|
|
8325
|
+
var _this$_container$owne, _this$_container;
|
|
8326
|
+
return (_this$_container$owne = (_this$_container = this._container) === null || _this$_container === void 0 ? void 0 : _this$_container.ownerDocument) !== null && _this$_container$owne !== void 0 ? _this$_container$owne : document;
|
|
8327
|
+
}
|
|
7938
8328
|
_getNodePosition(node) {
|
|
7939
8329
|
if (node == null) return;
|
|
7940
8330
|
const { node: glyph, ratioX, segmentPage } = node;
|
|
@@ -8070,6 +8460,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
8070
8460
|
const activeRangeInstance = this._getActiveRangeInstance();
|
|
8071
8461
|
const anchor = activeRangeInstance === null || activeRangeInstance === void 0 ? void 0 : activeRangeInstance.getAnchor();
|
|
8072
8462
|
if (!anchor || anchor && !anchor.visible || this.activeViewPort == null) {
|
|
8463
|
+
if (this._shouldPreserveExternalFocus()) return;
|
|
8073
8464
|
this.focus();
|
|
8074
8465
|
return;
|
|
8075
8466
|
}
|
|
@@ -8166,12 +8557,15 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
8166
8557
|
}
|
|
8167
8558
|
_initInputEvents() {
|
|
8168
8559
|
this.disposeWithMe(fromEvent(this._input, "keydown").subscribe((e) => {
|
|
8560
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8169
8561
|
if (this._isIMEInputApply) return;
|
|
8562
|
+
this._stopEmbedOwnedEditorShortcutPropagation(e);
|
|
8170
8563
|
this._eventHandle(e, (config) => {
|
|
8171
8564
|
this._onKeydown$.next(config);
|
|
8172
8565
|
});
|
|
8173
8566
|
}));
|
|
8174
8567
|
this.disposeWithMe(fromEvent(this._input, "input").subscribe((e) => {
|
|
8568
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8175
8569
|
if (e.inputType === "historyUndo" || e.inputType === "historyRedo") return;
|
|
8176
8570
|
if (this._rectRangeList.length > 0) {
|
|
8177
8571
|
e.stopPropagation();
|
|
@@ -8184,6 +8578,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
8184
8578
|
});
|
|
8185
8579
|
}));
|
|
8186
8580
|
this.disposeWithMe(fromEvent(this._input, "compositionstart").subscribe((e) => {
|
|
8581
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8187
8582
|
if (this._rectRangeList.length > 0) {
|
|
8188
8583
|
e.stopPropagation();
|
|
8189
8584
|
return e.preventDefault();
|
|
@@ -8194,28 +8589,33 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
8194
8589
|
});
|
|
8195
8590
|
}));
|
|
8196
8591
|
this.disposeWithMe(fromEvent(this._input, "compositionend").subscribe((e) => {
|
|
8592
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8197
8593
|
this._isIMEInputApply = false;
|
|
8198
8594
|
this._eventHandle(e, (config) => {
|
|
8199
8595
|
this._onCompositionend$.next(config);
|
|
8200
8596
|
});
|
|
8201
8597
|
}));
|
|
8202
8598
|
this.disposeWithMe(fromEvent(this._input, "compositionupdate").subscribe((e) => {
|
|
8599
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8203
8600
|
this._eventHandle(e, (config) => {
|
|
8204
8601
|
this._onInputBefore$.next(config);
|
|
8205
8602
|
this._onCompositionupdate$.next(config);
|
|
8206
8603
|
});
|
|
8207
8604
|
}));
|
|
8208
8605
|
this.disposeWithMe(fromEvent(this._input, "paste").subscribe((e) => {
|
|
8606
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8209
8607
|
this._eventHandle(e, (config) => {
|
|
8210
8608
|
this._onPaste$.next(config);
|
|
8211
8609
|
});
|
|
8212
8610
|
}));
|
|
8213
8611
|
this.disposeWithMe(fromEvent(this._input, "focus").subscribe((e) => {
|
|
8612
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8214
8613
|
this._eventHandle(e, (config) => {
|
|
8215
8614
|
this._onFocus$.next(config);
|
|
8216
8615
|
});
|
|
8217
8616
|
}));
|
|
8218
8617
|
this.disposeWithMe(fromEvent(this._input, "blur").subscribe((e) => {
|
|
8618
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8219
8619
|
this._eventHandle(e, (config) => {
|
|
8220
8620
|
this._onBlur$.next(config);
|
|
8221
8621
|
});
|
|
@@ -8231,6 +8631,26 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
8231
8631
|
rangeList: this._getAllTextRanges()
|
|
8232
8632
|
});
|
|
8233
8633
|
}
|
|
8634
|
+
_shouldSuppressHostHiddenEditorEvent(event) {
|
|
8635
|
+
var _this$_embedRuntimeFo, _this$_embedRuntimeFo2, _this$_embedRuntimeFo3;
|
|
8636
|
+
const unitId = this._context.unitId;
|
|
8637
|
+
if (isInternalEditorID(unitId)) return false;
|
|
8638
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.isChildUnitRuntimeEvent(unitId, event.target, event)) return false;
|
|
8639
|
+
if ((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(unitId)) return false;
|
|
8640
|
+
if (event.target instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(event.target)) return false;
|
|
8641
|
+
if ((_this$_embedRuntimeFo3 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo3 === void 0 ? void 0 : _this$_embedRuntimeFo3.shouldSuppressHostInteraction(unitId, event.target, event)) {
|
|
8642
|
+
event.stopPropagation();
|
|
8643
|
+
if (event.cancelable) event.preventDefault();
|
|
8644
|
+
if (event.type === "focus" && event.target instanceof HTMLElement) event.target.blur();
|
|
8645
|
+
return true;
|
|
8646
|
+
}
|
|
8647
|
+
return false;
|
|
8648
|
+
}
|
|
8649
|
+
_stopEmbedOwnedEditorShortcutPropagation(event) {
|
|
8650
|
+
if (!(event instanceof KeyboardEvent) || !this._getCurrentEmbedOwner()) return;
|
|
8651
|
+
if (!(event.key.toLowerCase() === "a" && (event.metaKey || event.ctrlKey))) return;
|
|
8652
|
+
event.stopPropagation();
|
|
8653
|
+
}
|
|
8234
8654
|
_getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY) {
|
|
8235
8655
|
const { documentTransform } = this._context.mainComponent.getOffsetConfig();
|
|
8236
8656
|
if (this.activeViewPort == null || documentTransform == null) return;
|
|
@@ -8246,6 +8666,50 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
8246
8666
|
const { pageLayoutType = PageLayoutType.VERTICAL, pageMarginLeft, pageMarginTop } = document.getOffsetConfig();
|
|
8247
8667
|
return skeleton.findNodeByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop, restrictions);
|
|
8248
8668
|
}
|
|
8669
|
+
_shouldPreserveExternalFocus() {
|
|
8670
|
+
var _this$_embedRuntimeFo4, _this$_embedRuntimeFo5, _this$_embedRuntimeFo6, _this$_embedInteracti, _this$_embedInteracti2, _this$_embedInteracti3;
|
|
8671
|
+
const ownerDocument = this._getOwnerDocument();
|
|
8672
|
+
const activeElement = ownerDocument.activeElement;
|
|
8673
|
+
const currentEmbedOwner = this._getCurrentEmbedOwner();
|
|
8674
|
+
if ((_this$_embedRuntimeFo4 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo4 === void 0 ? void 0 : _this$_embedRuntimeFo4.isChildUnitInActiveSession(this._context.unitId)) return false;
|
|
8675
|
+
if ((_this$_embedRuntimeFo5 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo5 === void 0 ? void 0 : _this$_embedRuntimeFo5.isChildUnitRuntimeEvent(this._context.unitId, activeElement)) return false;
|
|
8676
|
+
if (activeElement instanceof HTMLElement && this._containsOwnEditorElement(activeElement)) return false;
|
|
8677
|
+
if (activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement)) return false;
|
|
8678
|
+
if ((_this$_embedRuntimeFo6 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo6 === void 0 ? void 0 : _this$_embedRuntimeFo6.shouldSuppressHostInteraction(this._context.unitId, activeElement)) return true;
|
|
8679
|
+
if (currentEmbedOwner && ((_this$_embedInteracti = this._embedInteractionBoundaryService) === null || _this$_embedInteracti === void 0 ? void 0 : _this$_embedInteracti.contains(currentEmbedOwner, activeElement))) return true;
|
|
8680
|
+
if (activeElement instanceof HTMLElement && this._containsCurrentLayoutElement(activeElement)) return false;
|
|
8681
|
+
return ((_this$_embedInteracti2 = this._embedInteractionBoundaryService) === null || _this$_embedInteracti2 === void 0 || (_this$_embedInteracti3 = _this$_embedInteracti2.hasRecentInteractionFor) === null || _this$_embedInteracti3 === void 0 ? void 0 : _this$_embedInteracti3.call(_this$_embedInteracti2, currentEmbedOwner, ownerDocument)) === true;
|
|
8682
|
+
}
|
|
8683
|
+
_containsCurrentEmbedRuntimeElement(element) {
|
|
8684
|
+
const currentEmbedOwner = this._getCurrentEmbedOwner();
|
|
8685
|
+
if (!currentEmbedOwner) return false;
|
|
8686
|
+
return this._getElementEmbedOwner(element) === currentEmbedOwner && this._containsCurrentLayoutElement(element);
|
|
8687
|
+
}
|
|
8688
|
+
_getCurrentEmbedOwner() {
|
|
8689
|
+
var _this$_layoutService, _ref, _this$_getElementEmbe;
|
|
8690
|
+
const rootContainerElement = (_this$_layoutService = this._layoutService) === null || _this$_layoutService === void 0 ? void 0 : _this$_layoutService.rootContainerElement;
|
|
8691
|
+
return (_ref = (_this$_getElementEmbe = this._getElementEmbedOwner(this._input)) !== null && _this$_getElementEmbe !== void 0 ? _this$_getElementEmbe : this._getElementEmbedOwner(this._container)) !== null && _ref !== void 0 ? _ref : this._getElementEmbedOwner(rootContainerElement instanceof HTMLElement ? rootContainerElement : void 0);
|
|
8692
|
+
}
|
|
8693
|
+
_getElementEmbedOwner(element) {
|
|
8694
|
+
var _element$closest$getA, _element$closest;
|
|
8695
|
+
if (!element || typeof element.closest !== "function") return;
|
|
8696
|
+
return (_element$closest$getA = (_element$closest = element.closest(`[${"data-embed-interaction-boundary-owner"}]`)) === null || _element$closest === void 0 ? void 0 : _element$closest.getAttribute("data-embed-interaction-boundary-owner")) !== null && _element$closest$getA !== void 0 ? _element$closest$getA : void 0;
|
|
8697
|
+
}
|
|
8698
|
+
_containsOwnEditorElement(element) {
|
|
8699
|
+
var _this$_container2, _this$_inputParent;
|
|
8700
|
+
return this._container === element || this._input === element || typeof ((_this$_container2 = this._container) === null || _this$_container2 === void 0 ? void 0 : _this$_container2.contains) === "function" && this._container.contains(element) || typeof ((_this$_inputParent = this._inputParent) === null || _this$_inputParent === void 0 ? void 0 : _this$_inputParent.contains) === "function" && this._inputParent.contains(element);
|
|
8701
|
+
}
|
|
8702
|
+
_containsCurrentLayoutElement(element) {
|
|
8703
|
+
var _layoutService$checkE, _this$_container4;
|
|
8704
|
+
const layoutService = this._layoutService;
|
|
8705
|
+
if (!layoutService) {
|
|
8706
|
+
var _this$_container3;
|
|
8707
|
+
return this._container === element || typeof ((_this$_container3 = this._container) === null || _this$_container3 === void 0 ? void 0 : _this$_container3.contains) === "function" && this._container.contains(element);
|
|
8708
|
+
}
|
|
8709
|
+
if ((_layoutService$checkE = layoutService.checkElementInCurrentContainers) === null || _layoutService$checkE === void 0 ? void 0 : _layoutService$checkE.call(layoutService, element)) return true;
|
|
8710
|
+
const root = layoutService.rootContainerElement;
|
|
8711
|
+
return root === element || (root === null || root === void 0 ? void 0 : root.contains(element)) === true || this._container === element || typeof ((_this$_container4 = this._container) === null || _this$_container4 === void 0 ? void 0 : _this$_container4.contains) === "function" && this._container.contains(element);
|
|
8712
|
+
}
|
|
8249
8713
|
_detachEvent() {
|
|
8250
8714
|
this._onInputBefore$.complete();
|
|
8251
8715
|
this._onKeydown$.complete();
|
|
@@ -8259,13 +8723,16 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
8259
8723
|
this._onFocus$.complete();
|
|
8260
8724
|
this._onBlur$.complete();
|
|
8261
8725
|
this._onPointerDown$.complete();
|
|
8726
|
+
this._segmentContext$.complete();
|
|
8262
8727
|
}
|
|
8263
8728
|
};
|
|
8264
8729
|
DocSelectionRenderService = __decorate([
|
|
8265
8730
|
__decorateParam(1, ILayoutService),
|
|
8266
8731
|
__decorateParam(2, ILogService),
|
|
8267
8732
|
__decorateParam(3, IUniverInstanceService),
|
|
8268
|
-
__decorateParam(4, Inject(DocSkeletonManagerService))
|
|
8733
|
+
__decorateParam(4, Inject(DocSkeletonManagerService)),
|
|
8734
|
+
__decorateParam(5, Optional(IDocEmbedInteractionBoundaryService)),
|
|
8735
|
+
__decorateParam(6, Optional(IDocEmbedRuntimeFocusCoordinator))
|
|
8269
8736
|
], DocSelectionRenderService);
|
|
8270
8737
|
|
|
8271
8738
|
//#endregion
|
|
@@ -8387,10 +8854,10 @@ function canInsertTableAtOffset(body, offset) {
|
|
|
8387
8854
|
return !(isOffsetInTableRange(body.tables, offset) || isOffsetInIndexRange(body.blockRanges, offset) || isOffsetOnPointRange(body.customBlocks, offset));
|
|
8388
8855
|
}
|
|
8389
8856
|
function isOffsetInTableRange(ranges, offset) {
|
|
8390
|
-
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) => range
|
|
8857
|
+
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) => containsInteriorInsertionOffset(getTableRangeInterval(range), offset)));
|
|
8391
8858
|
}
|
|
8392
8859
|
function isOffsetInIndexRange(ranges, offset) {
|
|
8393
|
-
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) => range
|
|
8860
|
+
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) => containsInteriorInsertionOffset(getBlockRangeInterval(range), offset)));
|
|
8394
8861
|
}
|
|
8395
8862
|
function isOffsetOnPointRange(ranges, offset) {
|
|
8396
8863
|
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) => range.startIndex === offset));
|
|
@@ -8428,7 +8895,9 @@ const CreateDocTableCommand = {
|
|
|
8428
8895
|
if (skeleton == null) return false;
|
|
8429
8896
|
const startOffset = normalizeTableInsertOffset(body, (_contentInsertRange$s2 = contentInsertRange === null || contentInsertRange === void 0 ? void 0 : contentInsertRange.startOffset) !== null && _contentInsertRange$s2 !== void 0 ? _contentInsertRange$s2 : activeRange.startOffset);
|
|
8430
8897
|
if (!canInsertTableAtOffset(body, startOffset)) return false;
|
|
8431
|
-
const prevParagraph = ((_body$paragraphs = body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).find((
|
|
8898
|
+
const prevParagraph = ((_body$paragraphs = body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).find((paragraph) => {
|
|
8899
|
+
return getParagraphContentStartOffset(body, paragraph) < startOffset && startOffset <= paragraph.startIndex;
|
|
8900
|
+
});
|
|
8432
8901
|
const curGlyph = skeleton.findNodeByCharIndex(startOffset, segmentId, segmentPage);
|
|
8433
8902
|
if (curGlyph == null) return false;
|
|
8434
8903
|
const needCreateParagraph = shouldCreateParagraphBeforeTable(body, startOffset);
|
|
@@ -9205,11 +9674,14 @@ var Editor = class extends Disposable {
|
|
|
9205
9674
|
body: {
|
|
9206
9675
|
dataStream: `${text}\r\n`,
|
|
9207
9676
|
paragraphs: [{
|
|
9208
|
-
startIndex:
|
|
9677
|
+
startIndex: text.length,
|
|
9209
9678
|
paragraphId: createParagraphId(/* @__PURE__ */ new Set())
|
|
9210
9679
|
}],
|
|
9211
9680
|
customRanges: [],
|
|
9212
|
-
sectionBreaks: [
|
|
9681
|
+
sectionBreaks: [{
|
|
9682
|
+
sectionId: createSectionId(/* @__PURE__ */ new Set()),
|
|
9683
|
+
startIndex: text.length + 1
|
|
9684
|
+
}],
|
|
9213
9685
|
tables: [],
|
|
9214
9686
|
textRuns: []
|
|
9215
9687
|
}
|
|
@@ -9579,6 +10051,7 @@ DocBackScrollRenderController = __decorate([
|
|
|
9579
10051
|
//#region src/controllers/render-controllers/doc-paragraph-placeholder.render-controller.ts
|
|
9580
10052
|
const PLACEHOLDER_COLOR = "rgba(0, 0, 0, 0.35)";
|
|
9581
10053
|
const DEFAULT_PLACEHOLDER_FONT_SIZE = 12;
|
|
10054
|
+
const MIN_BODY_TEXT_PLACEHOLDER_FONT_SIZE = 16;
|
|
9582
10055
|
const DEFAULT_PLACEHOLDER_FONT_FAMILY = "Arial";
|
|
9583
10056
|
const LIST_PLACEHOLDER_GAP = 4;
|
|
9584
10057
|
let DocParagraphPlaceholderRenderController = class DocParagraphPlaceholderRenderController extends Disposable {
|
|
@@ -9672,11 +10145,11 @@ function getPlaceholderText(paragraph, locale) {
|
|
|
9672
10145
|
}
|
|
9673
10146
|
}
|
|
9674
10147
|
function getLinePlaceholderLayout(line, paragraph, text, originLeft, originTop) {
|
|
9675
|
-
var _divide$glyphGroup, _paragraph$paragraphS2, _paragraph$paragraphS3,
|
|
10148
|
+
var _divide$glyphGroup, _paragraph$paragraphS2, _paragraph$paragraphS3, _getLineFontFamily, _divide$left, _divide$paddingLeft, _ref, _divide$width;
|
|
9676
10149
|
const divide = line.divides[0];
|
|
9677
10150
|
const firstGlyph = ((_divide$glyphGroup = divide === null || divide === void 0 ? void 0 : divide.glyphGroup) !== null && _divide$glyphGroup !== void 0 ? _divide$glyphGroup : [])[0];
|
|
9678
10151
|
const textStyle = NAMED_STYLE_MAP[(_paragraph$paragraphS2 = (_paragraph$paragraphS3 = paragraph.paragraphStyle) === null || _paragraph$paragraphS3 === void 0 ? void 0 : _paragraph$paragraphS3.namedStyleType) !== null && _paragraph$paragraphS2 !== void 0 ? _paragraph$paragraphS2 : NamedStyleType.NORMAL_TEXT];
|
|
9679
|
-
const fontSize = (
|
|
10152
|
+
const fontSize = getPlaceholderFontSize(line, paragraph);
|
|
9680
10153
|
const fontFamily = (_getLineFontFamily = getLineFontFamily(line)) !== null && _getLineFontFamily !== void 0 ? _getLineFontFamily : DEFAULT_PLACEHOLDER_FONT_FAMILY;
|
|
9681
10154
|
const fontWeight = (textStyle === null || textStyle === void 0 ? void 0 : textStyle.bl) ? "bold" : "normal";
|
|
9682
10155
|
const lineStartX = originLeft + ((_divide$left = divide === null || divide === void 0 ? void 0 : divide.left) !== null && _divide$left !== void 0 ? _divide$left : 0) + ((_divide$paddingLeft = divide === null || divide === void 0 ? void 0 : divide.paddingLeft) !== null && _divide$paddingLeft !== void 0 ? _divide$paddingLeft : 0);
|
|
@@ -9685,7 +10158,7 @@ function getLinePlaceholderLayout(line, paragraph, text, originLeft, originTop)
|
|
|
9685
10158
|
fontFamily,
|
|
9686
10159
|
fontSize,
|
|
9687
10160
|
fontWeight,
|
|
9688
|
-
maxWidth: Math.max(0, ((
|
|
10161
|
+
maxWidth: Math.max(0, ((_ref = (_divide$width = divide === null || divide === void 0 ? void 0 : divide.width) !== null && _divide$width !== void 0 ? _divide$width : line.width) !== null && _ref !== void 0 ? _ref : 0) - listOffset),
|
|
9689
10162
|
text,
|
|
9690
10163
|
x: lineStartX + listOffset,
|
|
9691
10164
|
y: originTop + line.top + line.marginTop + line.paddingTop + line.asc
|
|
@@ -9700,12 +10173,20 @@ function stripNonTextTokens(text) {
|
|
|
9700
10173
|
}
|
|
9701
10174
|
function getLineFontSize(line) {
|
|
9702
10175
|
for (const divide of line.divides) for (const glyph of divide.glyphGroup) {
|
|
9703
|
-
var
|
|
9704
|
-
const fontSize = (
|
|
10176
|
+
var _ref2, _glyph$fontStyle$orig, _glyph$fontStyle, _glyph$fontStyle2, _glyph$ts;
|
|
10177
|
+
const fontSize = (_ref2 = (_glyph$fontStyle$orig = (_glyph$fontStyle = glyph.fontStyle) === null || _glyph$fontStyle === void 0 ? void 0 : _glyph$fontStyle.originFontSize) !== null && _glyph$fontStyle$orig !== void 0 ? _glyph$fontStyle$orig : (_glyph$fontStyle2 = glyph.fontStyle) === null || _glyph$fontStyle2 === void 0 ? void 0 : _glyph$fontStyle2.fontSize) !== null && _ref2 !== void 0 ? _ref2 : (_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.fs;
|
|
9705
10178
|
if (fontSize) return fontSize;
|
|
9706
10179
|
}
|
|
9707
10180
|
return null;
|
|
9708
10181
|
}
|
|
10182
|
+
function getPlaceholderFontSize(line, paragraph) {
|
|
10183
|
+
var _paragraph$paragraphS4, _paragraph$paragraphS5, _ref3, _getLineFontSize;
|
|
10184
|
+
const namedStyleType = (_paragraph$paragraphS4 = (_paragraph$paragraphS5 = paragraph.paragraphStyle) === null || _paragraph$paragraphS5 === void 0 ? void 0 : _paragraph$paragraphS5.namedStyleType) !== null && _paragraph$paragraphS4 !== void 0 ? _paragraph$paragraphS4 : NamedStyleType.NORMAL_TEXT;
|
|
10185
|
+
const textStyle = NAMED_STYLE_MAP[namedStyleType];
|
|
10186
|
+
const fontSize = (_ref3 = (_getLineFontSize = getLineFontSize(line)) !== null && _getLineFontSize !== void 0 ? _getLineFontSize : textStyle === null || textStyle === void 0 ? void 0 : textStyle.fs) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_PLACEHOLDER_FONT_SIZE;
|
|
10187
|
+
if (namedStyleType !== NamedStyleType.NORMAL_TEXT) return fontSize;
|
|
10188
|
+
return Math.max(fontSize, MIN_BODY_TEXT_PLACEHOLDER_FONT_SIZE);
|
|
10189
|
+
}
|
|
9709
10190
|
function getLineFontFamily(line) {
|
|
9710
10191
|
for (const divide of line.divides) for (const glyph of divide.glyphGroup) {
|
|
9711
10192
|
var _glyph$fontStyle$font, _glyph$fontStyle3, _glyph$ts2;
|
|
@@ -9789,11 +10270,11 @@ let DocViewScaleService = class DocViewScaleService extends Disposable {
|
|
|
9789
10270
|
return (_this$getPluginConfig = this.getPluginConfig().fitToWidth) !== null && _this$getPluginConfig !== void 0 ? _this$getPluginConfig : DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS;
|
|
9790
10271
|
}
|
|
9791
10272
|
getBaseWidth() {
|
|
9792
|
-
var _documentStyle$pageSi;
|
|
9793
|
-
const documentStyle = this._context.unit.getSnapshot().documentStyle;
|
|
10273
|
+
var _this$_context$unit, _this$_context$unit$g, _documentStyle$pageSi;
|
|
10274
|
+
const documentStyle = (_this$_context$unit = this._context.unit) === null || _this$_context$unit === void 0 || (_this$_context$unit$g = _this$_context$unit.getSnapshot) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.call(_this$_context$unit)) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.documentStyle;
|
|
9794
10275
|
return resolveDocFitBaseWidth({
|
|
9795
|
-
documentFlavor: documentStyle.documentFlavor,
|
|
9796
|
-
documentStylePageWidth: (_documentStyle$pageSi = documentStyle.pageSize) === null || _documentStyle$pageSi === void 0 ? void 0 : _documentStyle$pageSi.width
|
|
10276
|
+
documentFlavor: documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor,
|
|
10277
|
+
documentStylePageWidth: documentStyle === null || documentStyle === void 0 || (_documentStyle$pageSi = documentStyle.pageSize) === null || _documentStyle$pageSi === void 0 ? void 0 : _documentStyle$pageSi.width
|
|
9797
10278
|
});
|
|
9798
10279
|
}
|
|
9799
10280
|
getAvailableWidth() {
|
|
@@ -9806,6 +10287,7 @@ let DocViewScaleService = class DocViewScaleService extends Disposable {
|
|
|
9806
10287
|
return this._context.engine.width;
|
|
9807
10288
|
}
|
|
9808
10289
|
getUserZoomRatio() {
|
|
10290
|
+
if (this._context.unit == null) return 1;
|
|
9809
10291
|
return getDocEffectiveZoomRatio(this._context.unit);
|
|
9810
10292
|
}
|
|
9811
10293
|
getFitToWidthScale() {
|
|
@@ -9883,7 +10365,7 @@ DocPageLayoutService = __decorate([__decorateParam(1, Inject(DocViewScaleService
|
|
|
9883
10365
|
//#endregion
|
|
9884
10366
|
//#region src/controllers/render-controllers/doc.render-controller.ts
|
|
9885
10367
|
let DocRenderController = class DocRenderController extends RxDisposable {
|
|
9886
|
-
constructor(_context, _commandService, _docSelectionRenderService, _docSkeletonManagerService, _editorService, _renderManagerService, _univerInstanceService, _docPageLayoutService, _textSelectionManagerService, _themeService) {
|
|
10368
|
+
constructor(_context, _commandService, _docSelectionRenderService, _docSkeletonManagerService, _editorService, _renderManagerService, _univerInstanceService, _docPageLayoutService, _textSelectionManagerService, _docViewScaleService, _themeService) {
|
|
9887
10369
|
super();
|
|
9888
10370
|
this._context = _context;
|
|
9889
10371
|
this._commandService = _commandService;
|
|
@@ -9894,6 +10376,7 @@ let DocRenderController = class DocRenderController extends RxDisposable {
|
|
|
9894
10376
|
this._univerInstanceService = _univerInstanceService;
|
|
9895
10377
|
this._docPageLayoutService = _docPageLayoutService;
|
|
9896
10378
|
this._textSelectionManagerService = _textSelectionManagerService;
|
|
10379
|
+
this._docViewScaleService = _docViewScaleService;
|
|
9897
10380
|
this._themeService = _themeService;
|
|
9898
10381
|
this._addNewRender();
|
|
9899
10382
|
this._initRenderRefresh();
|
|
@@ -9940,7 +10423,7 @@ let DocRenderController = class DocRenderController extends RxDisposable {
|
|
|
9940
10423
|
else e.preventDefault();
|
|
9941
10424
|
} else viewMain.onMouseWheel(e, state);
|
|
9942
10425
|
});
|
|
9943
|
-
new ScrollBar(viewMain);
|
|
10426
|
+
new ScrollBar(viewMain, { enableHorizontal: this._shouldEnableHorizontalScrollBar() });
|
|
9944
10427
|
scene.addLayer(new Layer(scene, [], 2), new Layer(scene, [], 4));
|
|
9945
10428
|
this._addComponent();
|
|
9946
10429
|
const frameFn = () => scene.render();
|
|
@@ -9950,6 +10433,10 @@ let DocRenderController = class DocRenderController extends RxDisposable {
|
|
|
9950
10433
|
}));
|
|
9951
10434
|
this._docSelectionRenderService.__attachScrollEvent();
|
|
9952
10435
|
}
|
|
10436
|
+
_shouldEnableHorizontalScrollBar() {
|
|
10437
|
+
const options = this._docViewScaleService.getOptions();
|
|
10438
|
+
return !(options.mode === "fit-width" && options.target === "container" && options.align === "start");
|
|
10439
|
+
}
|
|
9953
10440
|
_addComponent() {
|
|
9954
10441
|
const { scene, unit: documentModel, components } = this._context;
|
|
9955
10442
|
const config = {
|
|
@@ -10085,7 +10572,8 @@ DocRenderController = __decorate([
|
|
|
10085
10572
|
__decorateParam(6, IUniverInstanceService),
|
|
10086
10573
|
__decorateParam(7, Inject(DocPageLayoutService)),
|
|
10087
10574
|
__decorateParam(8, Inject(DocSelectionManagerService)),
|
|
10088
|
-
__decorateParam(9, Inject(
|
|
10575
|
+
__decorateParam(9, Inject(DocViewScaleService)),
|
|
10576
|
+
__decorateParam(10, Inject(ThemeService))
|
|
10089
10577
|
], DocRenderController);
|
|
10090
10578
|
function getPageSizeInModernMode(page) {
|
|
10091
10579
|
let { pageWidth, pageHeight } = page;
|
|
@@ -10186,25 +10674,35 @@ const CoreHeaderFooterCommand = {
|
|
|
10186
10674
|
const commandService = accessor.get(ICommandService);
|
|
10187
10675
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
10188
10676
|
const renderManagerService = accessor.get(IRenderManagerService);
|
|
10189
|
-
const { unitId, segmentId, createType, headerFooterProps } = params;
|
|
10677
|
+
const { unitId, segmentId, createType, headerFooterProps, sectionId: requestedSectionId } = params;
|
|
10190
10678
|
const docSkeletonManagerService = (_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(DocSkeletonManagerService);
|
|
10191
10679
|
const docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
10192
10680
|
const docViewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
10193
10681
|
if (docDataModel == null || docViewModel == null) return false;
|
|
10194
10682
|
const editArea = docViewModel.getEditArea();
|
|
10195
|
-
const
|
|
10683
|
+
const snapshot = docDataModel.getSnapshot();
|
|
10684
|
+
const sectionId = requestedSectionId;
|
|
10685
|
+
const sections = snapshot.body ? getTopLevelSectionBreaks(snapshot.body) : [];
|
|
10686
|
+
const sectionIndex = sectionId == null ? -1 : sections.findIndex((section) => section.sectionId === sectionId);
|
|
10687
|
+
const section = sectionIndex < 0 ? void 0 : sections[sectionIndex];
|
|
10688
|
+
const headerFooterConfig = sectionId == null ? snapshot.documentStyle : {
|
|
10689
|
+
...snapshot.documentStyle,
|
|
10690
|
+
...section,
|
|
10691
|
+
...resolveSectionHeaderFooterReferences(snapshot.documentStyle, sections, sectionIndex)
|
|
10692
|
+
};
|
|
10196
10693
|
let resolvedCreateType = createType;
|
|
10197
10694
|
if (headerFooterProps != null) Object.keys(headerFooterProps).forEach((key) => {
|
|
10198
10695
|
const value = headerFooterProps[key];
|
|
10199
|
-
if (resolvedCreateType == null && key === "useFirstPageHeaderFooter" && value === BooleanNumber.TRUE && !
|
|
10200
|
-
else if (resolvedCreateType == null && key === "evenAndOddHeaders" && value === BooleanNumber.TRUE && !
|
|
10696
|
+
if (resolvedCreateType == null && key === "useFirstPageHeaderFooter" && value === BooleanNumber.TRUE && !headerFooterConfig.firstPageHeaderId) resolvedCreateType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.FIRST_PAGE_HEADER : HeaderFooterType.FIRST_PAGE_FOOTER;
|
|
10697
|
+
else if (resolvedCreateType == null && key === "evenAndOddHeaders" && value === BooleanNumber.TRUE && !headerFooterConfig.evenPageHeaderId) resolvedCreateType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.EVEN_PAGE_HEADER : HeaderFooterType.EVEN_PAGE_FOOTER;
|
|
10201
10698
|
});
|
|
10202
10699
|
return commandService.syncExecuteCommand(CreateHeaderFooterCommand.id, {
|
|
10203
10700
|
unitId,
|
|
10204
10701
|
segmentId,
|
|
10205
10702
|
createType: resolvedCreateType,
|
|
10206
10703
|
headerFooterProps,
|
|
10207
|
-
createMode: "pair"
|
|
10704
|
+
createMode: sectionId == null ? "pair" : "single",
|
|
10705
|
+
sectionId
|
|
10208
10706
|
});
|
|
10209
10707
|
}
|
|
10210
10708
|
};
|
|
@@ -10310,6 +10808,73 @@ const DocParagraphSettingPanelOperation = {
|
|
|
10310
10808
|
}
|
|
10311
10809
|
};
|
|
10312
10810
|
|
|
10811
|
+
//#endregion
|
|
10812
|
+
//#region src/views/section-setting/component-name.ts
|
|
10813
|
+
/**
|
|
10814
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
10815
|
+
*
|
|
10816
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10817
|
+
* you may not use this file except in compliance with the License.
|
|
10818
|
+
* You may obtain a copy of the License at
|
|
10819
|
+
*
|
|
10820
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10821
|
+
*
|
|
10822
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10823
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10824
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10825
|
+
* See the License for the specific language governing permissions and
|
|
10826
|
+
* limitations under the License.
|
|
10827
|
+
*/
|
|
10828
|
+
const DOC_SECTION_SETTING_COMPONENT = "doc_ui_section-setting-panel";
|
|
10829
|
+
|
|
10830
|
+
//#endregion
|
|
10831
|
+
//#region src/controllers/doc-section-setting.controller.ts
|
|
10832
|
+
/**
|
|
10833
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
10834
|
+
*
|
|
10835
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10836
|
+
* you may not use this file except in compliance with the License.
|
|
10837
|
+
* You may obtain a copy of the License at
|
|
10838
|
+
*
|
|
10839
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10840
|
+
*
|
|
10841
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10842
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10843
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10844
|
+
* See the License for the specific language governing permissions and
|
|
10845
|
+
* limitations under the License.
|
|
10846
|
+
*/
|
|
10847
|
+
let DocSectionSettingController = class DocSectionSettingController extends Disposable {
|
|
10848
|
+
constructor(_sidebarService) {
|
|
10849
|
+
super();
|
|
10850
|
+
this._sidebarService = _sidebarService;
|
|
10851
|
+
_defineProperty(this, "_panelId", "DocSectionSetting");
|
|
10852
|
+
}
|
|
10853
|
+
openPanel() {
|
|
10854
|
+
this._sidebarService.open({
|
|
10855
|
+
header: { title: "docs-ui.doc.slider.sectionSetting" },
|
|
10856
|
+
id: this._panelId,
|
|
10857
|
+
children: { label: DOC_SECTION_SETTING_COMPONENT },
|
|
10858
|
+
width: 300
|
|
10859
|
+
});
|
|
10860
|
+
}
|
|
10861
|
+
closePanel() {
|
|
10862
|
+
this._sidebarService.close(this._panelId);
|
|
10863
|
+
}
|
|
10864
|
+
};
|
|
10865
|
+
DocSectionSettingController = __decorate([__decorateParam(0, Inject(ISidebarService))], DocSectionSettingController);
|
|
10866
|
+
|
|
10867
|
+
//#endregion
|
|
10868
|
+
//#region src/commands/operations/doc-section-setting-panel.operation.ts
|
|
10869
|
+
const DocSectionSettingPanelOperation = {
|
|
10870
|
+
id: "sidebar.operation.doc-section-setting-panel",
|
|
10871
|
+
type: CommandType.OPERATION,
|
|
10872
|
+
handler: (accessor) => {
|
|
10873
|
+
accessor.get(DocSectionSettingController).openPanel();
|
|
10874
|
+
return true;
|
|
10875
|
+
}
|
|
10876
|
+
};
|
|
10877
|
+
|
|
10313
10878
|
//#endregion
|
|
10314
10879
|
//#region src/views/PageSettings.tsx
|
|
10315
10880
|
const MODERN_WIDTH_OPTIONS = [
|
|
@@ -10387,29 +10952,15 @@ function PageSettings(props) {
|
|
|
10387
10952
|
}
|
|
10388
10953
|
}));
|
|
10389
10954
|
};
|
|
10390
|
-
const handleModeChange = (mode) => {
|
|
10391
|
-
setSettings((prev) => ({
|
|
10392
|
-
...prev,
|
|
10393
|
-
mode
|
|
10394
|
-
}));
|
|
10395
|
-
};
|
|
10396
10955
|
const handleModernWidthChange = (modernWidth) => {
|
|
10397
10956
|
setSettings((prev) => ({
|
|
10398
10957
|
...prev,
|
|
10399
10958
|
modernWidth
|
|
10400
10959
|
}));
|
|
10401
10960
|
};
|
|
10402
|
-
return /* @__PURE__ */
|
|
10961
|
+
return /* @__PURE__ */ jsx("div", {
|
|
10403
10962
|
className: "univer-flex univer-flex-col univer-gap-4",
|
|
10404
|
-
children:
|
|
10405
|
-
className: "univer-grid univer-grid-cols-2 univer-rounded-lg univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800",
|
|
10406
|
-
children: [DocumentFlavor.MODERN, DocumentFlavor.TRADITIONAL].map((mode) => /* @__PURE__ */ jsx("button", {
|
|
10407
|
-
type: "button",
|
|
10408
|
-
className: clsx("univer-h-8 univer-cursor-pointer univer-rounded-md univer-border-none univer-bg-transparent univer-text-sm univer-font-medium univer-text-gray-600 univer-transition-colors hover:univer-bg-white hover:univer-text-gray-900 dark:!univer-text-gray-200 dark:hover:!univer-bg-gray-700", { "univer-bg-white univer-text-gray-900 univer-shadow-sm dark:!univer-bg-gray-700 dark:!univer-text-white": settings.mode === mode }),
|
|
10409
|
-
onClick: () => handleModeChange(mode),
|
|
10410
|
-
children: localeService.t(mode === DocumentFlavor.MODERN ? "docs-ui.page-settings.modern-mode" : "docs-ui.page-settings.classic-mode")
|
|
10411
|
-
}, mode))
|
|
10412
|
-
}), settings.mode === DocumentFlavor.MODERN ? /* @__PURE__ */ jsxs("div", {
|
|
10963
|
+
children: settings.mode === DocumentFlavor.MODERN ? /* @__PURE__ */ jsxs("div", {
|
|
10413
10964
|
className: "univer-flex univer-flex-col univer-gap-2.5",
|
|
10414
10965
|
children: [/* @__PURE__ */ jsx(SettingsLabel, { children: localeService.t("docs-ui.page-settings.modern-width") }), /* @__PURE__ */ jsx("div", {
|
|
10415
10966
|
className: "univer-grid univer-grid-cols-3 univer-gap-2",
|
|
@@ -10493,7 +11044,7 @@ function PageSettings(props) {
|
|
|
10493
11044
|
})]
|
|
10494
11045
|
})]
|
|
10495
11046
|
})]
|
|
10496
|
-
})] })
|
|
11047
|
+
})] })
|
|
10497
11048
|
});
|
|
10498
11049
|
}
|
|
10499
11050
|
const PAGE_SETTING_COMPONENT_ID = "docs.component.page-setting";
|
|
@@ -10797,12 +11348,38 @@ function TableInsertMenuItemFactory(accessor) {
|
|
|
10797
11348
|
})
|
|
10798
11349
|
};
|
|
10799
11350
|
}
|
|
10800
|
-
function
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
11351
|
+
function getSectionSettingUnavailableObservable(accessor) {
|
|
11352
|
+
const selectionManager = accessor.get(DocSelectionManagerService);
|
|
11353
|
+
const instanceService = accessor.get(IUniverInstanceService);
|
|
11354
|
+
return new Observable((subscriber) => {
|
|
11355
|
+
const emit = () => {
|
|
11356
|
+
var _body$tables;
|
|
11357
|
+
const documentDataModel = instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
11358
|
+
const activeRange = selectionManager.getActiveTextRange();
|
|
11359
|
+
const body = documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getBody();
|
|
11360
|
+
const unavailable = !documentDataModel || documentDataModel.getDocumentStyle().documentFlavor !== DocumentFlavor.TRADITIONAL || !activeRange || Boolean(activeRange.segmentId) || Boolean(body === null || body === void 0 || (_body$tables = body.tables) === null || _body$tables === void 0 ? void 0 : _body$tables.some((table) => activeRange.startOffset > table.startIndex && activeRange.startOffset < table.endIndex));
|
|
11361
|
+
subscriber.next(unavailable);
|
|
11362
|
+
};
|
|
11363
|
+
emit();
|
|
11364
|
+
const subscription = selectionManager.textSelection$.subscribe(emit);
|
|
11365
|
+
return () => subscription.unsubscribe();
|
|
11366
|
+
});
|
|
11367
|
+
}
|
|
11368
|
+
function SectionSettingMenuFactory(accessor) {
|
|
11369
|
+
return {
|
|
11370
|
+
id: DocSectionSettingPanelOperation.id,
|
|
11371
|
+
type: MenuItemType.BUTTON,
|
|
11372
|
+
icon: "MenuIcon",
|
|
11373
|
+
title: "docs-ui.doc.menu.sectionSetting",
|
|
11374
|
+
hidden$: combineLatest(getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), getSectionSettingUnavailableObservable(accessor), (hidden, unavailable) => hidden || unavailable)
|
|
11375
|
+
};
|
|
11376
|
+
}
|
|
11377
|
+
function InsertRowBeforeMenuItemFactory(accessor) {
|
|
11378
|
+
return {
|
|
11379
|
+
id: DocTableInsertRowAboveCommand.id,
|
|
11380
|
+
type: MenuItemType.BUTTON,
|
|
11381
|
+
title: "docs-ui.table.insertRowAbove",
|
|
11382
|
+
icon: "InsertRowAboveDoubleIcon",
|
|
10806
11383
|
disabled$: getDisableWhenSelectionNotInTableObservable(accessor),
|
|
10807
11384
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
10808
11385
|
};
|
|
@@ -11022,6 +11599,24 @@ const BULLET_LIST_TYPE_COMPONENT = `${COMPONENT_PREFIX}_BULLET_LIST_TYPE_COMPONE
|
|
|
11022
11599
|
|
|
11023
11600
|
//#endregion
|
|
11024
11601
|
//#region src/menu/menu.ts
|
|
11602
|
+
function shouldSuppressDocMenuStateRefresh(accessor) {
|
|
11603
|
+
let univerInstanceService;
|
|
11604
|
+
let focusCoordinator;
|
|
11605
|
+
try {
|
|
11606
|
+
univerInstanceService = accessor.get(IUniverInstanceService);
|
|
11607
|
+
} catch (error) {
|
|
11608
|
+
if (isInjectorDisposedError(error)) return true;
|
|
11609
|
+
throw error;
|
|
11610
|
+
}
|
|
11611
|
+
try {
|
|
11612
|
+
focusCoordinator = accessor.get(IDocEmbedRuntimeFocusCoordinator);
|
|
11613
|
+
} catch {
|
|
11614
|
+
return false;
|
|
11615
|
+
}
|
|
11616
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
11617
|
+
const unitId = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId();
|
|
11618
|
+
return focusCoordinator.shouldSuppressHostInteraction(unitId);
|
|
11619
|
+
}
|
|
11025
11620
|
function getInsertTableHiddenObservable(accessor) {
|
|
11026
11621
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
11027
11622
|
const renderManagerService = accessor.get(IRenderManagerService);
|
|
@@ -11215,6 +11810,7 @@ function BoldMenuItemFactory(accessor) {
|
|
|
11215
11810
|
activated$: new Observable((subscriber) => {
|
|
11216
11811
|
const calc = () => {
|
|
11217
11812
|
var _textRun$ts;
|
|
11813
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11218
11814
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11219
11815
|
if (textRun == null) {
|
|
11220
11816
|
subscriber.next(false);
|
|
@@ -11245,6 +11841,7 @@ function ItalicMenuItemFactory(accessor) {
|
|
|
11245
11841
|
activated$: new Observable((subscriber) => {
|
|
11246
11842
|
const calc = () => {
|
|
11247
11843
|
var _textRun$ts2;
|
|
11844
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11248
11845
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11249
11846
|
if (textRun == null) {
|
|
11250
11847
|
subscriber.next(false);
|
|
@@ -11275,6 +11872,7 @@ function UnderlineMenuItemFactory(accessor) {
|
|
|
11275
11872
|
activated$: new Observable((subscriber) => {
|
|
11276
11873
|
const calc = () => {
|
|
11277
11874
|
var _textRun$ts3;
|
|
11875
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11278
11876
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11279
11877
|
if (textRun == null) {
|
|
11280
11878
|
subscriber.next(false);
|
|
@@ -11305,6 +11903,7 @@ function StrikeThroughMenuItemFactory(accessor) {
|
|
|
11305
11903
|
activated$: new Observable((subscriber) => {
|
|
11306
11904
|
const calc = () => {
|
|
11307
11905
|
var _textRun$ts4;
|
|
11906
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11308
11907
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11309
11908
|
if (textRun == null) {
|
|
11310
11909
|
subscriber.next(false);
|
|
@@ -11334,6 +11933,7 @@ function SubscriptMenuItemFactory(accessor) {
|
|
|
11334
11933
|
activated$: new Observable((subscriber) => {
|
|
11335
11934
|
const calc = () => {
|
|
11336
11935
|
var _textRun$ts5;
|
|
11936
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11337
11937
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11338
11938
|
if (textRun == null) {
|
|
11339
11939
|
subscriber.next(false);
|
|
@@ -11363,6 +11963,7 @@ function SuperscriptMenuItemFactory(accessor) {
|
|
|
11363
11963
|
activated$: new Observable((subscriber) => {
|
|
11364
11964
|
const calc = () => {
|
|
11365
11965
|
var _textRun$ts6;
|
|
11966
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11366
11967
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11367
11968
|
if (textRun == null) {
|
|
11368
11969
|
subscriber.next(false);
|
|
@@ -11402,6 +12003,7 @@ function FontFamilySelectorMenuItemFactory(accessor) {
|
|
|
11402
12003
|
const defaultValue = DEFAULT_STYLES.ff;
|
|
11403
12004
|
const calc = () => {
|
|
11404
12005
|
var _textRun$ts7;
|
|
12006
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11405
12007
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11406
12008
|
if (textRun == null) {
|
|
11407
12009
|
subscriber.next(defaultValue);
|
|
@@ -11439,6 +12041,7 @@ function FontSizeSelectorMenuItemFactory(accessor) {
|
|
|
11439
12041
|
const DEFAULT_SIZE = DEFAULT_STYLES.fs;
|
|
11440
12042
|
const calc = () => {
|
|
11441
12043
|
var _textRun$ts8;
|
|
12044
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11442
12045
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11443
12046
|
if (textRun == null) {
|
|
11444
12047
|
subscriber.next(DEFAULT_SIZE);
|
|
@@ -11482,6 +12085,7 @@ function HeadingSelectorMenuItemFactory(accessor) {
|
|
|
11482
12085
|
const DEFAULT_TYPE = NamedStyleType.NORMAL_TEXT;
|
|
11483
12086
|
const calc = () => {
|
|
11484
12087
|
var _paragraph$paragraphS, _paragraph$paragraphS2;
|
|
12088
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11485
12089
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11486
12090
|
if (paragraph == null) {
|
|
11487
12091
|
subscriber.next(DEFAULT_TYPE);
|
|
@@ -11572,6 +12176,7 @@ function FloatTextStyleMenuItemFactory(accessor) {
|
|
|
11572
12176
|
selections: FLOAT_TEXT_STYLE_OPTIONS,
|
|
11573
12177
|
value$: new Observable((subscriber) => {
|
|
11574
12178
|
const calc = () => {
|
|
12179
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11575
12180
|
subscriber.next(normalizeFloatingTextStyleValue(getParagraphStyleAtCursor(accessor)));
|
|
11576
12181
|
};
|
|
11577
12182
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
@@ -11603,6 +12208,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
|
|
|
11603
12208
|
const defaultValue = DEFAULT_STYLES.cl.rgb;
|
|
11604
12209
|
const calc = () => {
|
|
11605
12210
|
var _textRun$ts9;
|
|
12211
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11606
12212
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11607
12213
|
if (!textRun) {
|
|
11608
12214
|
subscriber.next(defaultValue);
|
|
@@ -11622,6 +12228,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
|
|
|
11622
12228
|
const defaultColor = themeService.getColorFromTheme("gray.900");
|
|
11623
12229
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
11624
12230
|
if (c.id === SetInlineFormatTextColorCommand.id) {
|
|
12231
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11625
12232
|
const color = c.params.value;
|
|
11626
12233
|
subscriber.next(color !== null && color !== void 0 ? color : defaultColor);
|
|
11627
12234
|
}
|
|
@@ -11694,6 +12301,7 @@ function AlignLeftMenuItemFactory(accessor) {
|
|
|
11694
12301
|
const id = c.id;
|
|
11695
12302
|
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
11696
12303
|
var _paragraph$paragraphS5;
|
|
12304
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11697
12305
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11698
12306
|
if (paragraph == null) return;
|
|
11699
12307
|
const alignType = (_paragraph$paragraphS5 = paragraph.paragraphStyle) === null || _paragraph$paragraphS5 === void 0 ? void 0 : _paragraph$paragraphS5.horizontalAlign;
|
|
@@ -11718,6 +12326,7 @@ function AlignCenterMenuItemFactory(accessor) {
|
|
|
11718
12326
|
const id = c.id;
|
|
11719
12327
|
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
11720
12328
|
var _paragraph$paragraphS6;
|
|
12329
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11721
12330
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11722
12331
|
if (paragraph == null) return;
|
|
11723
12332
|
const alignType = (_paragraph$paragraphS6 = paragraph.paragraphStyle) === null || _paragraph$paragraphS6 === void 0 ? void 0 : _paragraph$paragraphS6.horizontalAlign;
|
|
@@ -11743,6 +12352,7 @@ function AlignRightMenuItemFactory(accessor) {
|
|
|
11743
12352
|
const id = c.id;
|
|
11744
12353
|
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
11745
12354
|
var _paragraph$paragraphS7;
|
|
12355
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11746
12356
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11747
12357
|
if (paragraph == null) return;
|
|
11748
12358
|
const alignType = (_paragraph$paragraphS7 = paragraph.paragraphStyle) === null || _paragraph$paragraphS7 === void 0 ? void 0 : _paragraph$paragraphS7.horizontalAlign;
|
|
@@ -11768,6 +12378,7 @@ function AlignJustifyMenuItemFactory(accessor) {
|
|
|
11768
12378
|
const id = c.id;
|
|
11769
12379
|
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
11770
12380
|
var _paragraph$paragraphS8;
|
|
12381
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11771
12382
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11772
12383
|
if (paragraph == null) return;
|
|
11773
12384
|
const alignType = (_paragraph$paragraphS8 = paragraph.paragraphStyle) === null || _paragraph$paragraphS8 === void 0 ? void 0 : _paragraph$paragraphS8.horizontalAlign;
|
|
@@ -11812,6 +12423,10 @@ function AlignMenuItemFactory(accessor) {
|
|
|
11812
12423
|
const value$ = new Observable((subscriber) => {
|
|
11813
12424
|
const calc = () => {
|
|
11814
12425
|
var _paragraph$paragraphS9, _paragraph$paragraphS10;
|
|
12426
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) {
|
|
12427
|
+
subscriber.next(HorizontalAlign.LEFT);
|
|
12428
|
+
return;
|
|
12429
|
+
}
|
|
11815
12430
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11816
12431
|
subscriber.next((_paragraph$paragraphS9 = paragraph === null || paragraph === void 0 || (_paragraph$paragraphS10 = paragraph.paragraphStyle) === null || _paragraph$paragraphS10 === void 0 ? void 0 : _paragraph$paragraphS10.horizontalAlign) !== null && _paragraph$paragraphS9 !== void 0 ? _paragraph$paragraphS9 : HorizontalAlign.LEFT);
|
|
11817
12432
|
};
|
|
@@ -11851,6 +12466,7 @@ const listValueFactory$ = (accessor) => {
|
|
|
11851
12466
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
11852
12467
|
const subscription = univerInstanceService.focused$.subscribe((unitId) => {
|
|
11853
12468
|
var _docRanges$find;
|
|
12469
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11854
12470
|
if (unitId == null) return;
|
|
11855
12471
|
const docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
11856
12472
|
if (docDataModel == null) return;
|
|
@@ -11930,30 +12546,6 @@ function CheckListMenuItemFactory(accessor) {
|
|
|
11930
12546
|
activated$: listValueFactory$(accessor).pipe(map((v) => Boolean(v && v.indexOf("CHECK_LIST") === 0)))
|
|
11931
12547
|
};
|
|
11932
12548
|
}
|
|
11933
|
-
function DocSwitchModeMenuItemFactory(accessor) {
|
|
11934
|
-
const commandService = accessor.get(ICommandService);
|
|
11935
|
-
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
11936
|
-
return {
|
|
11937
|
-
id: SwitchDocModeCommand.id,
|
|
11938
|
-
type: MenuItemType.BUTTON,
|
|
11939
|
-
icon: "KeyboardIcon",
|
|
11940
|
-
tooltip: "docs-ui.toolbar.documentFlavor",
|
|
11941
|
-
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
|
|
11942
|
-
activated$: new Observable((subscriber) => {
|
|
11943
|
-
var _instance$getSnapshot2;
|
|
11944
|
-
const subscription = commandService.onCommandExecuted((c) => {
|
|
11945
|
-
if (c.id === RichTextEditingMutation.id) {
|
|
11946
|
-
var _instance$getSnapshot;
|
|
11947
|
-
const instance = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
11948
|
-
subscriber.next((instance === null || instance === void 0 || (_instance$getSnapshot = instance.getSnapshot()) === null || _instance$getSnapshot === void 0 ? void 0 : _instance$getSnapshot.documentStyle.documentFlavor) === DocumentFlavor.MODERN);
|
|
11949
|
-
}
|
|
11950
|
-
});
|
|
11951
|
-
const instance = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
11952
|
-
subscriber.next((instance === null || instance === void 0 || (_instance$getSnapshot2 = instance.getSnapshot()) === null || _instance$getSnapshot2 === void 0 ? void 0 : _instance$getSnapshot2.documentStyle.documentFlavor) === DocumentFlavor.MODERN);
|
|
11953
|
-
return () => subscription.dispose();
|
|
11954
|
-
})
|
|
11955
|
-
};
|
|
11956
|
-
}
|
|
11957
12549
|
function ResetTextColorMenuItemFactory(accessor) {
|
|
11958
12550
|
return {
|
|
11959
12551
|
id: ResetInlineFormatTextColorCommand.id,
|
|
@@ -11988,6 +12580,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
11988
12580
|
const defaultValue = themeService.getColorFromTheme("primary.600");
|
|
11989
12581
|
const calc = () => {
|
|
11990
12582
|
var _textRun$ts10;
|
|
12583
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11991
12584
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11992
12585
|
if (!textRun) {
|
|
11993
12586
|
subscriber.next(defaultValue);
|
|
@@ -12007,6 +12600,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
12007
12600
|
const defaultColor = themeService.getColorFromTheme("primary.600");
|
|
12008
12601
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
12009
12602
|
if (c.id === SetInlineFormatTextBackgroundColorCommand.id) {
|
|
12603
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
12010
12604
|
const color = c.params.value;
|
|
12011
12605
|
subscriber.next(color !== null && color !== void 0 ? color : defaultColor);
|
|
12012
12606
|
}
|
|
@@ -12020,9 +12614,18 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
12020
12614
|
}
|
|
12021
12615
|
function getFontStyleAtCursor(accessor) {
|
|
12022
12616
|
var _docRanges$find2, _docMenuStyleService$, _paragraph$paragraphS11, _paragraph$paragraphS12, _docDataModel$getSelf;
|
|
12023
|
-
|
|
12024
|
-
|
|
12025
|
-
|
|
12617
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
12618
|
+
let univerInstanceService;
|
|
12619
|
+
let textSelectionService;
|
|
12620
|
+
let docMenuStyleService;
|
|
12621
|
+
try {
|
|
12622
|
+
univerInstanceService = accessor.get(IUniverInstanceService);
|
|
12623
|
+
textSelectionService = accessor.get(DocSelectionManagerService);
|
|
12624
|
+
docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
12625
|
+
} catch (error) {
|
|
12626
|
+
if (isInjectorDisposedError(error)) return;
|
|
12627
|
+
throw error;
|
|
12628
|
+
}
|
|
12026
12629
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
12027
12630
|
const docRanges = textSelectionService.getDocRanges();
|
|
12028
12631
|
const activeRange = (_docRanges$find2 = docRanges.find((r) => r.isActive)) !== null && _docRanges$find2 !== void 0 ? _docRanges$find2 : docRanges[0];
|
|
@@ -12053,8 +12656,16 @@ function getFontStyleAtCursor(accessor) {
|
|
|
12053
12656
|
}
|
|
12054
12657
|
function getParagraphStyleAtCursor(accessor) {
|
|
12055
12658
|
var _docRanges$find3, _docDataModel$getSelf2;
|
|
12056
|
-
|
|
12057
|
-
|
|
12659
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
12660
|
+
let univerInstanceService;
|
|
12661
|
+
let textSelectionService;
|
|
12662
|
+
try {
|
|
12663
|
+
univerInstanceService = accessor.get(IUniverInstanceService);
|
|
12664
|
+
textSelectionService = accessor.get(DocSelectionManagerService);
|
|
12665
|
+
} catch (error) {
|
|
12666
|
+
if (isInjectorDisposedError(error)) return;
|
|
12667
|
+
throw error;
|
|
12668
|
+
}
|
|
12058
12669
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
12059
12670
|
const docRanges = textSelectionService.getDocRanges();
|
|
12060
12671
|
const activeRange = (_docRanges$find3 = docRanges.find((r) => r.isActive)) !== null && _docRanges$find3 !== void 0 ? _docRanges$find3 : docRanges[0];
|
|
@@ -12070,6 +12681,10 @@ function getParagraphStyleAtCursor(accessor) {
|
|
|
12070
12681
|
}
|
|
12071
12682
|
return null;
|
|
12072
12683
|
}
|
|
12684
|
+
function isInjectorDisposedError(error) {
|
|
12685
|
+
if (!(error instanceof Error)) return false;
|
|
12686
|
+
return error.name === "InjectorAlreadyDisposedError" || error.message.includes("Injector cannot be accessed after it was disposed");
|
|
12687
|
+
}
|
|
12073
12688
|
function PageSettingMenuItemFactory(accessor) {
|
|
12074
12689
|
return {
|
|
12075
12690
|
id: DocOpenPageSettingCommand.id,
|
|
@@ -12134,6 +12749,7 @@ function getHeadingActivatedObservable(accessor, headingType) {
|
|
|
12134
12749
|
const DEFAULT_TYPE = NamedStyleType.NORMAL_TEXT;
|
|
12135
12750
|
const calc = () => {
|
|
12136
12751
|
var _paragraph$paragraphS, _paragraph$paragraphS2;
|
|
12752
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
12137
12753
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
12138
12754
|
if (paragraph == null) {
|
|
12139
12755
|
subscriber.next(DEFAULT_TYPE === headingType);
|
|
@@ -12585,7 +13201,7 @@ function ParagraphMenuIndentIncreaseMenuItemFactory(accessor) {
|
|
|
12585
13201
|
return {
|
|
12586
13202
|
id: DOC_PARAGRAPH_T_INDENT_INCREASE_ID,
|
|
12587
13203
|
type: MenuItemType.BUTTON,
|
|
12588
|
-
icon: "
|
|
13204
|
+
icon: "LineIndentIncreaseIcon",
|
|
12589
13205
|
title: "docs-ui.paragraphMenu.increase",
|
|
12590
13206
|
tooltip: "docs-ui.paragraphMenu.increaseIndent",
|
|
12591
13207
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
@@ -12595,7 +13211,7 @@ function ParagraphMenuIndentDecreaseMenuItemFactory(accessor) {
|
|
|
12595
13211
|
return {
|
|
12596
13212
|
id: DOC_PARAGRAPH_T_INDENT_DECREASE_ID,
|
|
12597
13213
|
type: MenuItemType.BUTTON,
|
|
12598
|
-
icon: "
|
|
13214
|
+
icon: "LineIndentDecreaseIcon",
|
|
12599
13215
|
title: "docs-ui.paragraphMenu.decrease",
|
|
12600
13216
|
tooltip: "docs-ui.paragraphMenu.decreaseIndent",
|
|
12601
13217
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
@@ -12733,10 +13349,6 @@ const menuSchema = {
|
|
|
12733
13349
|
order: 10,
|
|
12734
13350
|
menuItemFactory: HeaderFooterMenuItemFactory
|
|
12735
13351
|
},
|
|
12736
|
-
[SwitchDocModeCommand.id]: {
|
|
12737
|
-
order: 11,
|
|
12738
|
-
menuItemFactory: DocSwitchModeMenuItemFactory
|
|
12739
|
-
},
|
|
12740
13352
|
[DocOpenPageSettingCommand.id]: {
|
|
12741
13353
|
order: 12,
|
|
12742
13354
|
menuItemFactory: PageSettingMenuItemFactory
|
|
@@ -12785,6 +13397,10 @@ const menuSchema = {
|
|
|
12785
13397
|
order: 0,
|
|
12786
13398
|
menuItemFactory: ParagraphSettingMenuFactory
|
|
12787
13399
|
},
|
|
13400
|
+
[DocSectionSettingPanelOperation.id]: {
|
|
13401
|
+
order: 1,
|
|
13402
|
+
menuItemFactory: SectionSettingMenuFactory
|
|
13403
|
+
},
|
|
12788
13404
|
[TABLE_INSERT_MENU_ID]: {
|
|
12789
13405
|
order: 1,
|
|
12790
13406
|
menuItemFactory: TableInsertMenuItemFactory,
|
|
@@ -12877,6 +13493,10 @@ const menuSchema = {
|
|
|
12877
13493
|
order: 0,
|
|
12878
13494
|
menuItemFactory: ParagraphSettingMenuFactory
|
|
12879
13495
|
},
|
|
13496
|
+
[DocSectionSettingPanelOperation.id]: {
|
|
13497
|
+
order: 1,
|
|
13498
|
+
menuItemFactory: SectionSettingMenuFactory
|
|
13499
|
+
},
|
|
12880
13500
|
[INSERT_BELLOW_MENU_ID]: {
|
|
12881
13501
|
order: 1,
|
|
12882
13502
|
menuItemFactory: DocInsertBellowMenuItemFactory,
|
|
@@ -12990,6 +13610,10 @@ const menuSchema = {
|
|
|
12990
13610
|
order: 0,
|
|
12991
13611
|
menuItemFactory: ParagraphSettingMenuFactory
|
|
12992
13612
|
},
|
|
13613
|
+
[DocSectionSettingPanelOperation.id]: {
|
|
13614
|
+
order: 1,
|
|
13615
|
+
menuItemFactory: SectionSettingMenuFactory
|
|
13616
|
+
},
|
|
12993
13617
|
[BulletListCommand.id]: {
|
|
12994
13618
|
order: 1,
|
|
12995
13619
|
menuItemFactory: EmptyParagraphBulletListMenuItemFactory
|
|
@@ -13622,6 +14246,11 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
|
|
|
13622
14246
|
this._univerInstanceService = _univerInstanceService;
|
|
13623
14247
|
this._commandService = _commandService;
|
|
13624
14248
|
}
|
|
14249
|
+
_shouldUpdateForCommand(commandInfo, unitId) {
|
|
14250
|
+
if (commandInfo.id !== SetDocZoomRatioOperation.id && commandInfo.id !== RichTextEditingMutation.id) return false;
|
|
14251
|
+
const params = commandInfo.params;
|
|
14252
|
+
return (params === null || params === void 0 ? void 0 : params.unitId) == null || params.unitId === unitId;
|
|
14253
|
+
}
|
|
13625
14254
|
_createRectPositionObserver(rect, currentRender) {
|
|
13626
14255
|
const calc = () => {
|
|
13627
14256
|
const { scene, engine } = currentRender;
|
|
@@ -13644,20 +14273,21 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
|
|
|
13644
14273
|
if (position == null) throw new Error(`Current render canvas not found, unitId: ${currentRender.unitId}`);
|
|
13645
14274
|
const position$ = new BehaviorSubject(position);
|
|
13646
14275
|
const disposable = new DisposableCollection();
|
|
13647
|
-
|
|
13648
|
-
|
|
14276
|
+
const updatePosition = () => {
|
|
14277
|
+
try {
|
|
13649
14278
|
const newPosition = calc();
|
|
13650
14279
|
if (newPosition) position$.next(newPosition);
|
|
13651
|
-
}
|
|
14280
|
+
} catch {}
|
|
14281
|
+
};
|
|
14282
|
+
disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
|
|
14283
|
+
if (this._shouldUpdateForCommand(commandInfo, currentRender.unitId)) updatePosition();
|
|
13652
14284
|
}));
|
|
13653
14285
|
const viewMain = currentRender.scene.getViewport("viewMain");
|
|
13654
14286
|
if (viewMain) disposable.add(viewMain.onScrollAfter$.subscribeEvent(() => {
|
|
13655
|
-
|
|
13656
|
-
if (newPosition) position$.next(newPosition);
|
|
14287
|
+
updatePosition();
|
|
13657
14288
|
}));
|
|
13658
14289
|
disposable.add(currentRender.scene.onTransformChange$.subscribeEvent(() => {
|
|
13659
|
-
|
|
13660
|
-
if (newPosition) position$.next(newPosition);
|
|
14290
|
+
updatePosition();
|
|
13661
14291
|
}));
|
|
13662
14292
|
return {
|
|
13663
14293
|
position,
|
|
@@ -13708,11 +14338,13 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
|
|
|
13708
14338
|
attachPopupToRect(rect, popup, unitId) {
|
|
13709
14339
|
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
13710
14340
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14341
|
+
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
13711
14342
|
const { position, position$, disposable } = this._createRectPositionObserver(rect, currentRender);
|
|
13712
14343
|
const id = this._globalPopupManagerService.addPopup({
|
|
13713
14344
|
...popup,
|
|
13714
14345
|
unitId,
|
|
13715
14346
|
subUnitId: "default",
|
|
14347
|
+
connectorInjector: popupInjector,
|
|
13716
14348
|
anchorRect: position,
|
|
13717
14349
|
anchorRect$: position$,
|
|
13718
14350
|
canvasElement: currentRender.engine.getCanvasElement()
|
|
@@ -13735,11 +14367,13 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
|
|
|
13735
14367
|
attachPopupToObject(targetObject, popup, unitId) {
|
|
13736
14368
|
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
13737
14369
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14370
|
+
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
13738
14371
|
const { position, position$, disposable } = this._createObjectPositionObserver(targetObject, currentRender);
|
|
13739
14372
|
const id = this._globalPopupManagerService.addPopup({
|
|
13740
14373
|
...popup,
|
|
13741
14374
|
unitId,
|
|
13742
14375
|
subUnitId: "default",
|
|
14376
|
+
connectorInjector: popupInjector,
|
|
13743
14377
|
anchorRect: position,
|
|
13744
14378
|
anchorRect$: position$,
|
|
13745
14379
|
canvasElement: currentRender.engine.getCanvasElement()
|
|
@@ -13765,12 +14399,14 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
|
|
|
13765
14399
|
const { direction = "top", multipleDirection } = popup;
|
|
13766
14400
|
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
13767
14401
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14402
|
+
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
13768
14403
|
const { positions: bounds, positions$: bounds$, disposable } = this._createRangePositionObserver(range, currentRender);
|
|
13769
14404
|
const position$ = bounds$.pipe(map((bounds) => direction.includes("top") ? bounds[0] : bounds[bounds.length - 1]));
|
|
13770
14405
|
const id = this._globalPopupManagerService.addPopup({
|
|
13771
14406
|
...popup,
|
|
13772
14407
|
unitId,
|
|
13773
14408
|
subUnitId: "default",
|
|
14409
|
+
connectorInjector: popupInjector,
|
|
13774
14410
|
anchorRect: direction.includes("top") ? bounds[0] : bounds[bounds.length - 1],
|
|
13775
14411
|
anchorRect$: position$,
|
|
13776
14412
|
excludeRects: bounds,
|
|
@@ -13791,6 +14427,10 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends Dispos
|
|
|
13791
14427
|
canDispose: () => this._globalPopupManagerService.activePopupId !== id
|
|
13792
14428
|
};
|
|
13793
14429
|
}
|
|
14430
|
+
_resolveEmbeddedPopupInjector(unitId, currentRender) {
|
|
14431
|
+
var _this$_univerInstance, _currentRender$getInj;
|
|
14432
|
+
return ((_this$_univerInstance = this._univerInstanceService.getUnitCreateOptions(unitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.embeddedRender) === true ? (_currentRender$getInj = currentRender.getInjector) === null || _currentRender$getInj === void 0 ? void 0 : _currentRender$getInj.call(currentRender) : void 0;
|
|
14433
|
+
}
|
|
13794
14434
|
};
|
|
13795
14435
|
DocCanvasPopManagerService = __decorate([
|
|
13796
14436
|
__decorateParam(0, Inject(ICanvasPopupService)),
|
|
@@ -14513,10 +15153,6 @@ function clipRectHorizontally(rect, visibleLeft, visibleRight) {
|
|
|
14513
15153
|
|
|
14514
15154
|
//#endregion
|
|
14515
15155
|
//#region src/views/SideMenu.tsx
|
|
14516
|
-
const commonClass = "univer-font-[500] univer-truncate univer-h-[24px] univer-mb-2 univer-leading-[24px] univer-cursor-pointer univer-pr-1 ";
|
|
14517
|
-
const titleClass = "univer-text-base univer-font-semibold";
|
|
14518
|
-
const h1Class = "univer-text-sm univer-font-semibold";
|
|
14519
|
-
const textClass = "univer-text-sm";
|
|
14520
15156
|
const SideMenu = forwardRef((props, ref) => {
|
|
14521
15157
|
const { menus, onClick, className, style, mode, maxHeight, activeId, open, onOpenChange, maxWidth, wrapperClass, wrapperStyle, iconClass, iconStyle } = props;
|
|
14522
15158
|
const isSideBar = mode === "side-bar";
|
|
@@ -14565,10 +15201,10 @@ const SideMenu = forwardRef((props, ref) => {
|
|
|
14565
15201
|
className: clsx("univer-flex-1 univer-overflow-y-auto univer-overflow-x-hidden", scrollbarClassName),
|
|
14566
15202
|
children: menus === null || menus === void 0 ? void 0 : menus.map((menu) => /* @__PURE__ */ jsx("div", {
|
|
14567
15203
|
id: `univer-side-menu-${menu.id}`,
|
|
14568
|
-
className: clsx(
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
|
|
15204
|
+
className: clsx("univer-mb-2 univer-h-[24px] univer-cursor-pointer univer-truncate univer-pr-1 univer-font-[500] univer-leading-[24px]", {
|
|
15205
|
+
"univer-text-base univer-font-semibold": menu.isTitle,
|
|
15206
|
+
"univer-text-sm univer-font-semibold": menu.level === 1,
|
|
15207
|
+
"univer-text-sm": menu.level > 1,
|
|
14572
15208
|
"univer-text-gray-500 dark:!univer-text-gray-400": menu.id !== activeId,
|
|
14573
15209
|
"univer-text-gray-800 dark:!univer-text-gray-200": menu.id === activeId
|
|
14574
15210
|
}),
|
|
@@ -14749,7 +15385,7 @@ function DocSideMenuContent() {
|
|
|
14749
15385
|
* limitations under the License.
|
|
14750
15386
|
*/
|
|
14751
15387
|
let DocUIController = class DocUIController extends Disposable {
|
|
14752
|
-
constructor(_injector, _commandService, _layoutService, _menuManagerService, _uiPartsService, _univerInstanceService, _shortcutService, _configService) {
|
|
15388
|
+
constructor(_injector, _commandService, _layoutService, _menuManagerService, _uiPartsService, _univerInstanceService, _shortcutService, _configService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
14753
15389
|
super();
|
|
14754
15390
|
this._injector = _injector;
|
|
14755
15391
|
this._commandService = _commandService;
|
|
@@ -14759,6 +15395,7 @@ let DocUIController = class DocUIController extends Disposable {
|
|
|
14759
15395
|
this._univerInstanceService = _univerInstanceService;
|
|
14760
15396
|
this._shortcutService = _shortcutService;
|
|
14761
15397
|
this._configService = _configService;
|
|
15398
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
14762
15399
|
this._init();
|
|
14763
15400
|
}
|
|
14764
15401
|
_initUiParts() {
|
|
@@ -14804,9 +15441,15 @@ let DocUIController = class DocUIController extends Disposable {
|
|
|
14804
15441
|
}
|
|
14805
15442
|
_initFocusHandler() {
|
|
14806
15443
|
this.disposeWithMe(this._layoutService.registerFocusHandler(UniverInstanceType.UNIVER_DOC, (unitId) => {
|
|
15444
|
+
if (this._shouldPreserveEmbedFocus(unitId)) return;
|
|
14807
15445
|
this._injector.get(IRenderManagerService).getRenderById(unitId).with(DocSelectionRenderService).focus();
|
|
14808
15446
|
}));
|
|
14809
15447
|
}
|
|
15448
|
+
_shouldPreserveEmbedFocus(unitId) {
|
|
15449
|
+
var _this$_embedRuntimeFo;
|
|
15450
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.shouldSuppressHostInteraction(unitId)) return true;
|
|
15451
|
+
return false;
|
|
15452
|
+
}
|
|
14810
15453
|
};
|
|
14811
15454
|
DocUIController = __decorate([
|
|
14812
15455
|
__decorateParam(0, Inject(Injector)),
|
|
@@ -14816,13 +15459,272 @@ DocUIController = __decorate([
|
|
|
14816
15459
|
__decorateParam(4, IUIPartsService),
|
|
14817
15460
|
__decorateParam(5, IUniverInstanceService),
|
|
14818
15461
|
__decorateParam(6, IShortcutService),
|
|
14819
|
-
__decorateParam(7, IConfigService)
|
|
15462
|
+
__decorateParam(7, IConfigService),
|
|
15463
|
+
__decorateParam(8, Optional(IDocEmbedInteractionBoundaryService)),
|
|
15464
|
+
__decorateParam(9, Optional(IDocEmbedRuntimeFocusCoordinator))
|
|
14820
15465
|
], DocUIController);
|
|
14821
15466
|
|
|
15467
|
+
//#endregion
|
|
15468
|
+
//#region src/embed-docs-custom-block-bleed.ts
|
|
15469
|
+
/**
|
|
15470
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
15471
|
+
*
|
|
15472
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15473
|
+
* you may not use this file except in compliance with the License.
|
|
15474
|
+
* You may obtain a copy of the License at
|
|
15475
|
+
*
|
|
15476
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15477
|
+
*
|
|
15478
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15479
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15480
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15481
|
+
* See the License for the specific language governing permissions and
|
|
15482
|
+
* limitations under the License.
|
|
15483
|
+
*/
|
|
15484
|
+
const DOCS_CUSTOM_BLOCK_VIEWPORT_INSET = 10;
|
|
15485
|
+
function createDefaultDocsTableLikeCustomBlockBleedViewport() {
|
|
15486
|
+
if (typeof window === "undefined") return {
|
|
15487
|
+
bleedLeft: 0,
|
|
15488
|
+
bleedRight: 0,
|
|
15489
|
+
bleedWidth: 1,
|
|
15490
|
+
contentWidth: 1,
|
|
15491
|
+
virtualWidth: 1
|
|
15492
|
+
};
|
|
15493
|
+
const bleedWidth = Math.max(1, window.innerWidth - DOCS_CUSTOM_BLOCK_VIEWPORT_INSET * 2);
|
|
15494
|
+
return {
|
|
15495
|
+
bleedLeft: 0,
|
|
15496
|
+
bleedRight: 0,
|
|
15497
|
+
bleedWidth,
|
|
15498
|
+
contentWidth: 1,
|
|
15499
|
+
virtualWidth: bleedWidth
|
|
15500
|
+
};
|
|
15501
|
+
}
|
|
15502
|
+
function resolveDocsTableLikeCustomBlockBleedViewport(root, contentWidth, hint) {
|
|
15503
|
+
const rootRect = root.getBoundingClientRect();
|
|
15504
|
+
const rootWidth = Math.max(1, rootRect.width);
|
|
15505
|
+
const normalizedContentWidth = Math.max(1, contentWidth);
|
|
15506
|
+
const hintedBleedLeft = hint === null || hint === void 0 ? void 0 : hint.bleedLeft;
|
|
15507
|
+
const hintedBleedWidth = hint === null || hint === void 0 ? void 0 : hint.bleedWidth;
|
|
15508
|
+
if (Number.isFinite(hintedBleedWidth) && (hintedBleedWidth !== null && hintedBleedWidth !== void 0 ? hintedBleedWidth : 0) > 0) {
|
|
15509
|
+
const bleedLeft = Math.max(0, hintedBleedLeft !== null && hintedBleedLeft !== void 0 ? hintedBleedLeft : 0);
|
|
15510
|
+
const bleedWidth = Math.max(1, hintedBleedWidth);
|
|
15511
|
+
return {
|
|
15512
|
+
bleedLeft,
|
|
15513
|
+
bleedRight: Math.max(0, bleedWidth - bleedLeft - rootWidth),
|
|
15514
|
+
bleedWidth,
|
|
15515
|
+
contentWidth: normalizedContentWidth,
|
|
15516
|
+
virtualWidth: Math.max(bleedWidth, bleedLeft + normalizedContentWidth)
|
|
15517
|
+
};
|
|
15518
|
+
}
|
|
15519
|
+
if (normalizedContentWidth <= rootWidth) return {
|
|
15520
|
+
bleedLeft: 0,
|
|
15521
|
+
bleedRight: 0,
|
|
15522
|
+
bleedWidth: rootWidth,
|
|
15523
|
+
contentWidth: normalizedContentWidth,
|
|
15524
|
+
virtualWidth: rootWidth
|
|
15525
|
+
};
|
|
15526
|
+
const bounds = resolveDocsTableLikeCustomBlockBleedBounds(root);
|
|
15527
|
+
const viewportLeft = bounds.left + DOCS_CUSTOM_BLOCK_VIEWPORT_INSET;
|
|
15528
|
+
const viewportWidth = Math.max(1, bounds.width - DOCS_CUSTOM_BLOCK_VIEWPORT_INSET * 2);
|
|
15529
|
+
const bleedLeft = Math.max(0, rootRect.left - viewportLeft);
|
|
15530
|
+
return {
|
|
15531
|
+
bleedLeft,
|
|
15532
|
+
bleedRight: Math.max(0, viewportLeft + viewportWidth - rootRect.right),
|
|
15533
|
+
bleedWidth: viewportWidth,
|
|
15534
|
+
contentWidth: normalizedContentWidth,
|
|
15535
|
+
virtualWidth: Math.max(viewportWidth, bleedLeft + normalizedContentWidth)
|
|
15536
|
+
};
|
|
15537
|
+
}
|
|
15538
|
+
function resolveDocsTableLikeCustomBlockContentWidth(authoritativeContentWidth, fallbackContentWidth) {
|
|
15539
|
+
return Number.isFinite(authoritativeContentWidth) && (authoritativeContentWidth !== null && authoritativeContentWidth !== void 0 ? authoritativeContentWidth : 0) > 0 ? authoritativeContentWidth : Math.max(1, fallbackContentWidth);
|
|
15540
|
+
}
|
|
15541
|
+
function resolveDocsTableLikeCustomBlockContentHeight(authoritativeContentHeight, fallbackContentHeight) {
|
|
15542
|
+
return Number.isFinite(authoritativeContentHeight) && (authoritativeContentHeight !== null && authoritativeContentHeight !== void 0 ? authoritativeContentHeight : 0) > 0 ? authoritativeContentHeight : Math.max(1, fallbackContentHeight);
|
|
15543
|
+
}
|
|
15544
|
+
function resolveDocsTableLikeCustomBlockBleedBounds(root) {
|
|
15545
|
+
const clippingAncestor = findClippingAncestor(root);
|
|
15546
|
+
if (clippingAncestor) {
|
|
15547
|
+
const rect = clippingAncestor.getBoundingClientRect();
|
|
15548
|
+
if (Number.isFinite(rect.width) && rect.width > 0) return {
|
|
15549
|
+
left: rect.left,
|
|
15550
|
+
width: rect.width
|
|
15551
|
+
};
|
|
15552
|
+
}
|
|
15553
|
+
return {
|
|
15554
|
+
left: 0,
|
|
15555
|
+
width: typeof window === "undefined" ? 1 : Math.max(1, window.innerWidth)
|
|
15556
|
+
};
|
|
15557
|
+
}
|
|
15558
|
+
function findClippingAncestor(root) {
|
|
15559
|
+
let current = root.parentElement;
|
|
15560
|
+
while (current && current !== document.body && current !== document.documentElement) {
|
|
15561
|
+
if (clipsOverflow(current)) return current;
|
|
15562
|
+
current = current.parentElement;
|
|
15563
|
+
}
|
|
15564
|
+
return null;
|
|
15565
|
+
}
|
|
15566
|
+
function clipsOverflow(element) {
|
|
15567
|
+
const style = window.getComputedStyle(element);
|
|
15568
|
+
return hasClippingOverflow(style.overflow) || hasClippingOverflow(style.overflowX) || hasClippingOverflow(style.overflowY);
|
|
15569
|
+
}
|
|
15570
|
+
function hasClippingOverflow(value) {
|
|
15571
|
+
return value === "hidden" || value === "auto" || value === "scroll" || value === "clip";
|
|
15572
|
+
}
|
|
15573
|
+
|
|
15574
|
+
//#endregion
|
|
15575
|
+
//#region src/embed-docs-custom-block-refresh.ts
|
|
15576
|
+
function collectDocsTableLikeEmbedChildUnitIds(drawings, resolveChildUnitId) {
|
|
15577
|
+
const childUnitIds = /* @__PURE__ */ new Set();
|
|
15578
|
+
Object.values(drawings !== null && drawings !== void 0 ? drawings : {}).forEach((drawing) => {
|
|
15579
|
+
var _resolveChildUnitId;
|
|
15580
|
+
const data = getDrawingData(drawing);
|
|
15581
|
+
const childUnitId = data ? (_resolveChildUnitId = resolveChildUnitId === null || resolveChildUnitId === void 0 ? void 0 : resolveChildUnitId(data)) !== null && _resolveChildUnitId !== void 0 ? _resolveChildUnitId : typeof data.childUnitId === "string" ? data.childUnitId : void 0 : void 0;
|
|
15582
|
+
const childType = typeof (data === null || data === void 0 ? void 0 : data.childType) === "number" ? data.childType : void 0;
|
|
15583
|
+
if (!childUnitId || !isSheetLikeDocsCustomBlockChildType$1(childType)) return;
|
|
15584
|
+
childUnitIds.add(childUnitId);
|
|
15585
|
+
});
|
|
15586
|
+
return childUnitIds;
|
|
15587
|
+
}
|
|
15588
|
+
function getDrawingData(drawing) {
|
|
15589
|
+
if (!drawing || typeof drawing !== "object") return;
|
|
15590
|
+
const data = drawing.data;
|
|
15591
|
+
return data && typeof data === "object" ? data : void 0;
|
|
15592
|
+
}
|
|
15593
|
+
function getCommandUnitId(commandParams) {
|
|
15594
|
+
if (!commandParams || typeof commandParams !== "object") return;
|
|
15595
|
+
const params = commandParams;
|
|
15596
|
+
if (typeof params.unitId === "string") return params.unitId;
|
|
15597
|
+
return typeof params.unitID === "string" ? params.unitID : void 0;
|
|
15598
|
+
}
|
|
15599
|
+
function shouldRefreshDocsCustomBlockSizeForCommand(params) {
|
|
15600
|
+
if (params.commandId && isDocsCustomBlockLayoutNeutralCommand(params.commandId)) return false;
|
|
15601
|
+
const commandUnitId = getCommandUnitId(params.commandParams);
|
|
15602
|
+
return Boolean(commandUnitId && commandUnitId !== params.hostUnitId && params.childUnitIds.has(commandUnitId));
|
|
15603
|
+
}
|
|
15604
|
+
const DOCS_CUSTOM_BLOCK_LAYOUT_NEUTRAL_COMMAND_IDS = /* @__PURE__ */ new Set([
|
|
15605
|
+
"sheet.command.expand-selection",
|
|
15606
|
+
"sheet.command.move-selection",
|
|
15607
|
+
"sheet.operation.scroll-to-cell",
|
|
15608
|
+
"sheet.operation.scroll-to-range",
|
|
15609
|
+
"sheet.operation.set-activate-cell-edit",
|
|
15610
|
+
"sheet.operation.set-cell-edit-visible",
|
|
15611
|
+
"sheet.operation.set-cell-edit-visible-arrow",
|
|
15612
|
+
"sheet.operation.set-cell-edit-visible-f2",
|
|
15613
|
+
"sheet.operation.set-format-painter",
|
|
15614
|
+
"sheet.operation.set-scroll",
|
|
15615
|
+
"sheet.operation.set-selections",
|
|
15616
|
+
"sheet.operation.set-zoom-ratio"
|
|
15617
|
+
]);
|
|
15618
|
+
function isDocsCustomBlockLayoutNeutralCommand(commandId) {
|
|
15619
|
+
return DOCS_CUSTOM_BLOCK_LAYOUT_NEUTRAL_COMMAND_IDS.has(commandId);
|
|
15620
|
+
}
|
|
15621
|
+
function createDocsCustomBlockSizeRefreshScheduler(refresh) {
|
|
15622
|
+
let pendingFrame;
|
|
15623
|
+
return {
|
|
15624
|
+
dispose: () => {
|
|
15625
|
+
if (pendingFrame == null) return;
|
|
15626
|
+
window.cancelAnimationFrame(pendingFrame);
|
|
15627
|
+
pendingFrame = void 0;
|
|
15628
|
+
},
|
|
15629
|
+
schedule: () => {
|
|
15630
|
+
if (pendingFrame != null) return;
|
|
15631
|
+
pendingFrame = window.requestAnimationFrame(() => {
|
|
15632
|
+
pendingFrame = void 0;
|
|
15633
|
+
refresh();
|
|
15634
|
+
});
|
|
15635
|
+
}
|
|
15636
|
+
};
|
|
15637
|
+
}
|
|
15638
|
+
|
|
15639
|
+
//#endregion
|
|
15640
|
+
//#region src/embed-docs-custom-block-scroll.ts
|
|
15641
|
+
function scrollDocsTableLikeCustomBlockLive(event, live, options = {}) {
|
|
15642
|
+
if (event.defaultPrevented || event.ctrlKey || event.metaKey) return false;
|
|
15643
|
+
const deltaX = event.deltaX || (event.shiftKey ? event.deltaY : 0);
|
|
15644
|
+
const deltaY = event.shiftKey ? 0 : event.deltaY;
|
|
15645
|
+
const previousLeft = live.scrollLeft;
|
|
15646
|
+
const previousTop = live.scrollTop;
|
|
15647
|
+
const maxScrollLeft = resolveMaxScrollLeft(live, options.maxScrollLeft);
|
|
15648
|
+
if (deltaX && canScrollX(live, deltaX, maxScrollLeft)) live.scrollLeft = clampScroll(previousLeft + deltaX, 0, maxScrollLeft);
|
|
15649
|
+
if (deltaY && canScrollY(live, deltaY)) live.scrollTop = clampScroll(previousTop + deltaY, 0, live.scrollHeight - live.clientHeight);
|
|
15650
|
+
return live.scrollLeft !== previousLeft || live.scrollTop !== previousTop;
|
|
15651
|
+
}
|
|
15652
|
+
function canScrollX(element, deltaX, maxScrollLeft) {
|
|
15653
|
+
return element.scrollWidth > element.clientWidth && (deltaX < 0 ? element.scrollLeft > 0 : element.scrollLeft < maxScrollLeft);
|
|
15654
|
+
}
|
|
15655
|
+
function canScrollY(element, deltaY) {
|
|
15656
|
+
return element.scrollHeight > element.clientHeight && (deltaY < 0 ? element.scrollTop > 0 : element.scrollTop + element.clientHeight < element.scrollHeight);
|
|
15657
|
+
}
|
|
15658
|
+
function clampScroll(value, min, max) {
|
|
15659
|
+
return Math.max(min, Math.min(max, value));
|
|
15660
|
+
}
|
|
15661
|
+
function resolveMaxScrollLeft(element, requestedMaxScrollLeft) {
|
|
15662
|
+
const nativeMaxScrollLeft = Math.max(0, element.scrollWidth - element.clientWidth);
|
|
15663
|
+
if (!Number.isFinite(requestedMaxScrollLeft)) return nativeMaxScrollLeft;
|
|
15664
|
+
return clampScroll(requestedMaxScrollLeft !== null && requestedMaxScrollLeft !== void 0 ? requestedMaxScrollLeft : nativeMaxScrollLeft, 0, nativeMaxScrollLeft);
|
|
15665
|
+
}
|
|
15666
|
+
|
|
15667
|
+
//#endregion
|
|
15668
|
+
//#region src/embed-host-anchor.ts
|
|
15669
|
+
const MODERN_DOCS_CUSTOM_BLOCK_VIEWPORT_INSET = 10;
|
|
15670
|
+
function resolveDocsCustomBlockRenderViewport(params) {
|
|
15671
|
+
var _params$fallbackWidth, _params$fallbackHeigh, _params$contentHeight, _params$visibleCanvas, _params$pageMarginLef, _params$pageMarginRig, _params$contentWidth, _params$docsLeft, _params$visibleCanvas2;
|
|
15672
|
+
const defaultSize = resolveDocsCustomBlockSize$1(params.childType);
|
|
15673
|
+
const fallbackWidth = (_params$fallbackWidth = params.fallbackWidth) !== null && _params$fallbackWidth !== void 0 ? _params$fallbackWidth : defaultSize.width;
|
|
15674
|
+
const fallbackHeight = (_params$fallbackHeigh = params.fallbackHeight) !== null && _params$fallbackHeigh !== void 0 ? _params$fallbackHeigh : defaultSize.height;
|
|
15675
|
+
const sheetLike = isSheetLikeDocsCustomBlockChildType$1(params.childType);
|
|
15676
|
+
const contentHeight = Number.isFinite(params.contentHeight) && ((_params$contentHeight = params.contentHeight) !== null && _params$contentHeight !== void 0 ? _params$contentHeight : 0) > 0 ? params.contentHeight : fallbackHeight;
|
|
15677
|
+
const visibleCanvasHeight = Number.isFinite(params.visibleCanvasHeight) && ((_params$visibleCanvas = params.visibleCanvasHeight) !== null && _params$visibleCanvas !== void 0 ? _params$visibleCanvas : 0) > 0 ? params.visibleCanvasHeight : void 0;
|
|
15678
|
+
const height = sheetLike ? contentHeight : fallbackHeight;
|
|
15679
|
+
const viewportHeight = sheetLike && visibleCanvasHeight != null ? Math.min(contentHeight, visibleCanvasHeight) : height;
|
|
15680
|
+
if (!sheetLike) return {
|
|
15681
|
+
height,
|
|
15682
|
+
width: fallbackWidth
|
|
15683
|
+
};
|
|
15684
|
+
const pageWidth = params.pageWidth;
|
|
15685
|
+
const pageMarginLeft = (_params$pageMarginLef = params.pageMarginLeft) !== null && _params$pageMarginLef !== void 0 ? _params$pageMarginLef : 0;
|
|
15686
|
+
const pageMarginRight = (_params$pageMarginRig = params.pageMarginRight) !== null && _params$pageMarginRig !== void 0 ? _params$pageMarginRig : 0;
|
|
15687
|
+
const pageContentWidth = Number.isFinite(pageWidth) ? Math.max(0, pageWidth - pageMarginLeft - pageMarginRight) : fallbackWidth;
|
|
15688
|
+
const contentWidth = Number.isFinite(params.contentWidth) && ((_params$contentWidth = params.contentWidth) !== null && _params$contentWidth !== void 0 ? _params$contentWidth : 0) > 0 ? params.contentWidth : fallbackWidth;
|
|
15689
|
+
if (params.documentFlavor !== DocumentFlavor.MODERN || !Number.isFinite(pageWidth)) {
|
|
15690
|
+
const layoutWidth = Math.min(contentWidth, pageContentWidth || contentWidth);
|
|
15691
|
+
return {
|
|
15692
|
+
contentHeight,
|
|
15693
|
+
contentWidth,
|
|
15694
|
+
height,
|
|
15695
|
+
layoutWidth,
|
|
15696
|
+
offsetLeft: 0,
|
|
15697
|
+
viewportHeight,
|
|
15698
|
+
width: layoutWidth
|
|
15699
|
+
};
|
|
15700
|
+
}
|
|
15701
|
+
const inset = MODERN_DOCS_CUSTOM_BLOCK_VIEWPORT_INSET / (params.scale && params.scale > 0 ? params.scale : 1);
|
|
15702
|
+
const docsLeft = (_params$docsLeft = params.docsLeft) !== null && _params$docsLeft !== void 0 ? _params$docsLeft : 0;
|
|
15703
|
+
const fallbackViewportLeft = docsLeft + inset;
|
|
15704
|
+
const fallbackViewportWidth = Math.max(0, pageWidth - inset * 2);
|
|
15705
|
+
const hasVisibleCanvas = Number.isFinite(params.visibleCanvasLeft) && Number.isFinite(params.visibleCanvasWidth) && ((_params$visibleCanvas2 = params.visibleCanvasWidth) !== null && _params$visibleCanvas2 !== void 0 ? _params$visibleCanvas2 : 0) > 0;
|
|
15706
|
+
const viewportLeft = hasVisibleCanvas ? params.visibleCanvasLeft + inset : fallbackViewportLeft;
|
|
15707
|
+
const viewportWidth = hasVisibleCanvas ? Math.max(0, params.visibleCanvasWidth - inset * 2) : fallbackViewportWidth;
|
|
15708
|
+
const paragraphTextStart = docsLeft + pageMarginLeft;
|
|
15709
|
+
const leadingInsetLeft = Math.max(0, paragraphTextStart - viewportLeft);
|
|
15710
|
+
const layoutWidth = Math.min(contentWidth, pageContentWidth || contentWidth);
|
|
15711
|
+
return {
|
|
15712
|
+
bleedLeft: leadingInsetLeft,
|
|
15713
|
+
bleedWidth: viewportWidth,
|
|
15714
|
+
contentHeight,
|
|
15715
|
+
contentWidth,
|
|
15716
|
+
height,
|
|
15717
|
+
layoutWidth,
|
|
15718
|
+
offsetLeft: 0,
|
|
15719
|
+
viewportHeight,
|
|
15720
|
+
width: layoutWidth
|
|
15721
|
+
};
|
|
15722
|
+
}
|
|
15723
|
+
|
|
14822
15724
|
//#endregion
|
|
14823
15725
|
//#region package.json
|
|
14824
15726
|
var name = "@univerjs/docs-ui";
|
|
14825
|
-
var version = "1.0.0-alpha.
|
|
15727
|
+
var version = "1.0.0-alpha.3";
|
|
14826
15728
|
|
|
14827
15729
|
//#endregion
|
|
14828
15730
|
//#region src/commands/commands/doc-paragraph-setting.command.ts
|
|
@@ -14830,7 +15732,7 @@ const DocParagraphSettingCommand = {
|
|
|
14830
15732
|
id: "doc-paragraph-setting.command",
|
|
14831
15733
|
type: CommandType.COMMAND,
|
|
14832
15734
|
handler: async (accessor, config) => {
|
|
14833
|
-
var
|
|
15735
|
+
var _segmentBody$paragrap, _segmentBody$dataStre, _BuildTextUtils$range;
|
|
14834
15736
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
14835
15737
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
14836
15738
|
const commandService = accessor.get(ICommandService);
|
|
@@ -14840,8 +15742,9 @@ const DocParagraphSettingCommand = {
|
|
|
14840
15742
|
const segmentId = docRanges[0].segmentId;
|
|
14841
15743
|
const unitId = docDataModel.getUnitId();
|
|
14842
15744
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
14843
|
-
const
|
|
14844
|
-
const
|
|
15745
|
+
const segmentBody = segment === null || segment === void 0 ? void 0 : segment.getBody();
|
|
15746
|
+
const allParagraphs = (_segmentBody$paragrap = segmentBody === null || segmentBody === void 0 ? void 0 : segmentBody.paragraphs) !== null && _segmentBody$paragrap !== void 0 ? _segmentBody$paragrap : [];
|
|
15747
|
+
const dataStream = (_segmentBody$dataStre = segmentBody === null || segmentBody === void 0 ? void 0 : segmentBody.dataStream) !== null && _segmentBody$dataStre !== void 0 ? _segmentBody$dataStre : "";
|
|
14845
15748
|
const paragraphs = (_BuildTextUtils$range = BuildTextUtils.range.getParagraphsInRanges(docRanges, allParagraphs, dataStream)) !== null && _BuildTextUtils$range !== void 0 ? _BuildTextUtils$range : [];
|
|
14846
15749
|
const doMutation = {
|
|
14847
15750
|
id: RichTextEditingMutation.id,
|
|
@@ -14851,6 +15754,7 @@ const DocParagraphSettingCommand = {
|
|
|
14851
15754
|
textRanges: docRanges
|
|
14852
15755
|
}
|
|
14853
15756
|
};
|
|
15757
|
+
if (!config.paragraph || Object.keys(config.paragraph).length === 0) return false;
|
|
14854
15758
|
const memoryCursor = new MemoryCursor();
|
|
14855
15759
|
memoryCursor.reset();
|
|
14856
15760
|
const textX = new TextX();
|
|
@@ -14861,10 +15765,6 @@ const DocParagraphSettingCommand = {
|
|
|
14861
15765
|
t: TextXActionType.RETAIN,
|
|
14862
15766
|
len: startIndex - memoryCursor.cursor
|
|
14863
15767
|
});
|
|
14864
|
-
const paragraphStyle = {
|
|
14865
|
-
...paragraph.paragraphStyle,
|
|
14866
|
-
...config.paragraph
|
|
14867
|
-
};
|
|
14868
15768
|
textX.push({
|
|
14869
15769
|
t: TextXActionType.RETAIN,
|
|
14870
15770
|
len: 1,
|
|
@@ -14872,7 +15772,10 @@ const DocParagraphSettingCommand = {
|
|
|
14872
15772
|
dataStream: "",
|
|
14873
15773
|
paragraphs: [{
|
|
14874
15774
|
...paragraph,
|
|
14875
|
-
paragraphStyle
|
|
15775
|
+
paragraphStyle: {
|
|
15776
|
+
...paragraph.paragraphStyle,
|
|
15777
|
+
...config.paragraph
|
|
15778
|
+
},
|
|
14876
15779
|
startIndex: 0
|
|
14877
15780
|
}]
|
|
14878
15781
|
},
|
|
@@ -14886,18 +15789,50 @@ const DocParagraphSettingCommand = {
|
|
|
14886
15789
|
}
|
|
14887
15790
|
};
|
|
14888
15791
|
|
|
15792
|
+
//#endregion
|
|
15793
|
+
//#region src/utils/section-header-footer.ts
|
|
15794
|
+
function getDocPageSectionContext(snapshot, page) {
|
|
15795
|
+
const sections = snapshot.body ? getTopLevelSectionBreaks(snapshot.body) : [];
|
|
15796
|
+
const sectionIndex = (page === null || page === void 0 ? void 0 : page.sectionId) == null ? -1 : sections.findIndex((item) => item.sectionId === page.sectionId);
|
|
15797
|
+
const section = sectionIndex < 0 ? void 0 : sections[sectionIndex];
|
|
15798
|
+
const references = section == null ? {} : resolveSectionHeaderFooterReferences(snapshot.documentStyle, sections, sectionIndex);
|
|
15799
|
+
return {
|
|
15800
|
+
sectionId: section === null || section === void 0 ? void 0 : section.sectionId,
|
|
15801
|
+
sectionIndex,
|
|
15802
|
+
sections,
|
|
15803
|
+
section,
|
|
15804
|
+
config: {
|
|
15805
|
+
...snapshot.documentStyle,
|
|
15806
|
+
...section,
|
|
15807
|
+
...references
|
|
15808
|
+
}
|
|
15809
|
+
};
|
|
15810
|
+
}
|
|
15811
|
+
|
|
14889
15812
|
//#endregion
|
|
14890
15813
|
//#region src/views/header-footer/panel/DocHeaderFooterOptions.tsx
|
|
14891
|
-
function getSegmentId(documentStyle, editArea, pageIndex) {
|
|
15814
|
+
function getSegmentId(documentStyle, editArea, pageIndex, page) {
|
|
14892
15815
|
const { useFirstPageHeaderFooter, evenAndOddHeaders, defaultHeaderId, defaultFooterId, firstPageHeaderId, firstPageFooterId, evenPageHeaderId, evenPageFooterId } = documentStyle;
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
else
|
|
14897
|
-
else return evenAndOddHeaders === BooleanNumber.TRUE &&
|
|
14898
|
-
else
|
|
15816
|
+
const isFirstPage = page ? page.pageNumber === page.pageNumberStart : pageIndex === 0;
|
|
15817
|
+
const isEvenPage = page ? page.pageNumber % 2 === 0 : pageIndex % 2 === 1;
|
|
15818
|
+
if (editArea === DocumentEditArea.HEADER) if (useFirstPageHeaderFooter === BooleanNumber.TRUE) if (isFirstPage) return firstPageHeaderId;
|
|
15819
|
+
else return evenAndOddHeaders === BooleanNumber.TRUE && isEvenPage ? evenPageHeaderId : defaultHeaderId;
|
|
15820
|
+
else return evenAndOddHeaders === BooleanNumber.TRUE && isEvenPage ? evenPageHeaderId : defaultHeaderId;
|
|
15821
|
+
else if (useFirstPageHeaderFooter === BooleanNumber.TRUE) if (isFirstPage) return firstPageFooterId;
|
|
15822
|
+
else return evenAndOddHeaders === BooleanNumber.TRUE && isEvenPage ? evenPageFooterId : defaultFooterId;
|
|
15823
|
+
else return evenAndOddHeaders === BooleanNumber.TRUE && isEvenPage ? evenPageFooterId : defaultFooterId;
|
|
14899
15824
|
}
|
|
14900
15825
|
const DocHeaderFooterOptions = (props) => {
|
|
15826
|
+
var _segmentContext$segme, _segmentContext$segme2;
|
|
15827
|
+
const docSelectionRenderService = useDependency(IRenderManagerService).getRenderById(props.unitId).with(DocSelectionRenderService);
|
|
15828
|
+
const segmentContext = useObservable(docSelectionRenderService.segmentContext$, {
|
|
15829
|
+
segmentId: docSelectionRenderService.getSegment(),
|
|
15830
|
+
segmentPage: docSelectionRenderService.getSegmentPage()
|
|
15831
|
+
});
|
|
15832
|
+
return /* @__PURE__ */ jsx(DocHeaderFooterOptionsContent, { ...props }, `${(_segmentContext$segme = segmentContext === null || segmentContext === void 0 ? void 0 : segmentContext.segmentId) !== null && _segmentContext$segme !== void 0 ? _segmentContext$segme : ""}:${(_segmentContext$segme2 = segmentContext === null || segmentContext === void 0 ? void 0 : segmentContext.segmentPage) !== null && _segmentContext$segme2 !== void 0 ? _segmentContext$segme2 : -1}`);
|
|
15833
|
+
};
|
|
15834
|
+
function DocHeaderFooterOptionsContent(props) {
|
|
15835
|
+
var _renderManagerService2, _sectionContext$confi, _sectionContext$secti, _sectionContext$secti2;
|
|
14901
15836
|
const localeService = useDependency(LocaleService);
|
|
14902
15837
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
14903
15838
|
const renderManagerService = useDependency(IRenderManagerService);
|
|
@@ -14905,31 +15840,57 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
14905
15840
|
const layoutService = useDependency(ILayoutService);
|
|
14906
15841
|
const { unitId } = props;
|
|
14907
15842
|
const docSelectionRenderService = renderManagerService.getRenderById(unitId).with(DocSelectionRenderService);
|
|
14908
|
-
const
|
|
15843
|
+
const docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
15844
|
+
const getCurrentSectionContext = () => {
|
|
15845
|
+
var _renderManagerService, _docSkeletonManagerSe;
|
|
15846
|
+
const snapshot = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot();
|
|
15847
|
+
const docSkeletonManagerService = (_renderManagerService = renderManagerService.getRenderById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(DocSkeletonManagerService);
|
|
15848
|
+
const page = docSkeletonManagerService === null || docSkeletonManagerService === void 0 || (_docSkeletonManagerSe = docSkeletonManagerService.getSkeleton) === null || _docSkeletonManagerSe === void 0 || (_docSkeletonManagerSe = _docSkeletonManagerSe.call(docSkeletonManagerService)) === null || _docSkeletonManagerSe === void 0 || (_docSkeletonManagerSe = _docSkeletonManagerSe.getSkeletonData()) === null || _docSkeletonManagerSe === void 0 ? void 0 : _docSkeletonManagerSe.pages[docSelectionRenderService.getSegmentPage()];
|
|
15849
|
+
return snapshot == null ? void 0 : {
|
|
15850
|
+
...getDocPageSectionContext(snapshot, page),
|
|
15851
|
+
page
|
|
15852
|
+
};
|
|
15853
|
+
};
|
|
15854
|
+
const [options, setOptions] = useState(() => {
|
|
15855
|
+
var _getCurrentSectionCon, _config$marginHeader, _config$marginFooter, _config$useFirstPageH, _config$evenAndOddHea;
|
|
15856
|
+
const config = (_getCurrentSectionCon = getCurrentSectionContext()) === null || _getCurrentSectionCon === void 0 ? void 0 : _getCurrentSectionCon.config;
|
|
15857
|
+
return {
|
|
15858
|
+
marginHeader: (_config$marginHeader = config === null || config === void 0 ? void 0 : config.marginHeader) !== null && _config$marginHeader !== void 0 ? _config$marginHeader : 0,
|
|
15859
|
+
marginFooter: (_config$marginFooter = config === null || config === void 0 ? void 0 : config.marginFooter) !== null && _config$marginFooter !== void 0 ? _config$marginFooter : 0,
|
|
15860
|
+
useFirstPageHeaderFooter: (_config$useFirstPageH = config === null || config === void 0 ? void 0 : config.useFirstPageHeaderFooter) !== null && _config$useFirstPageH !== void 0 ? _config$useFirstPageH : BooleanNumber.FALSE,
|
|
15861
|
+
evenAndOddHeaders: (_config$evenAndOddHea = config === null || config === void 0 ? void 0 : config.evenAndOddHeaders) !== null && _config$evenAndOddHea !== void 0 ? _config$evenAndOddHea : BooleanNumber.FALSE
|
|
15862
|
+
};
|
|
15863
|
+
});
|
|
15864
|
+
const sectionContext = getCurrentSectionContext();
|
|
15865
|
+
const referenceKey = getSectionHeaderFooterReferenceKey(((_renderManagerService2 = renderManagerService.getRenderById(unitId)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.with(DocSkeletonManagerService)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.getViewModel()) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.getEditArea()) === DocumentEditArea.FOOTER ? "footer" : "header", getHeaderFooterVariant((_sectionContext$confi = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config) !== null && _sectionContext$confi !== void 0 ? _sectionContext$confi : {}, docSelectionRenderService.getSegmentPage(), sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page));
|
|
15866
|
+
const canLinkToPrevious = ((_sectionContext$secti = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionIndex) !== null && _sectionContext$secti !== void 0 ? _sectionContext$secti : -1) > 0;
|
|
15867
|
+
const [linkedToPrevious, setLinkedToPrevious] = useState(canLinkToPrevious && !(sectionContext === null || sectionContext === void 0 || (_sectionContext$secti2 = sectionContext.section) === null || _sectionContext$secti2 === void 0 ? void 0 : _sectionContext$secti2[referenceKey]));
|
|
14909
15868
|
const handleCheckboxChange = (val, type) => {
|
|
14910
|
-
var
|
|
15869
|
+
var _renderManagerService3;
|
|
14911
15870
|
setOptions((prev) => ({
|
|
14912
15871
|
...prev,
|
|
14913
15872
|
[type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE
|
|
14914
15873
|
}));
|
|
14915
|
-
const
|
|
14916
|
-
const documentStyle =
|
|
14917
|
-
const docSkeletonManagerService = (
|
|
15874
|
+
const sectionContext = getCurrentSectionContext();
|
|
15875
|
+
const documentStyle = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config;
|
|
15876
|
+
const docSkeletonManagerService = (_renderManagerService3 = renderManagerService.getRenderById(unitId)) === null || _renderManagerService3 === void 0 ? void 0 : _renderManagerService3.with(DocSkeletonManagerService);
|
|
14918
15877
|
const viewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
14919
15878
|
if (documentStyle == null || viewModel == null) return;
|
|
14920
15879
|
const editArea = viewModel.getEditArea();
|
|
14921
15880
|
let needCreateHeaderFooter = false;
|
|
14922
15881
|
const segmentPage = docSelectionRenderService.getSegmentPage();
|
|
15882
|
+
const isFirstSectionPage = (sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page) ? sectionContext.page.pageNumber === sectionContext.page.pageNumberStart : segmentPage === 0;
|
|
15883
|
+
const isEvenPage = (sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page) ? sectionContext.page.pageNumber % 2 === 0 : segmentPage % 2 === 1;
|
|
14923
15884
|
let needChangeSegmentId = false;
|
|
14924
15885
|
if (type === "useFirstPageHeaderFooter" && val === true) {
|
|
14925
15886
|
if (editArea === DocumentEditArea.HEADER && !documentStyle.firstPageHeaderId) needCreateHeaderFooter = true;
|
|
14926
15887
|
else if (editArea === DocumentEditArea.FOOTER && !documentStyle.firstPageFooterId) needCreateHeaderFooter = true;
|
|
14927
|
-
if (needCreateHeaderFooter &&
|
|
15888
|
+
if (needCreateHeaderFooter && isFirstSectionPage) needChangeSegmentId = true;
|
|
14928
15889
|
}
|
|
14929
15890
|
if (type === "evenAndOddHeaders" && val === true) {
|
|
14930
15891
|
if (editArea === DocumentEditArea.HEADER && !documentStyle.evenPageHeaderId) needCreateHeaderFooter = true;
|
|
14931
15892
|
else if (editArea === DocumentEditArea.FOOTER && !documentStyle.evenPageFooterId) needCreateHeaderFooter = true;
|
|
14932
|
-
if (needCreateHeaderFooter &&
|
|
15893
|
+
if (needCreateHeaderFooter && isEvenPage) needChangeSegmentId = true;
|
|
14933
15894
|
}
|
|
14934
15895
|
if (needCreateHeaderFooter) {
|
|
14935
15896
|
const segmentId = generateRandomId(6);
|
|
@@ -14937,7 +15898,8 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
14937
15898
|
commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
14938
15899
|
unitId,
|
|
14939
15900
|
segmentId,
|
|
14940
|
-
headerFooterProps: { [type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE }
|
|
15901
|
+
headerFooterProps: { [type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE },
|
|
15902
|
+
sectionId: sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionId
|
|
14941
15903
|
});
|
|
14942
15904
|
} else {
|
|
14943
15905
|
const segmentPageIndex = docSelectionRenderService.getSegmentPage();
|
|
@@ -14945,23 +15907,26 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
14945
15907
|
const needFocusSegmentId = getSegmentId({
|
|
14946
15908
|
...documentStyle,
|
|
14947
15909
|
[type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE
|
|
14948
|
-
}, editArea, segmentPageIndex);
|
|
15910
|
+
}, editArea, segmentPageIndex, sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page);
|
|
14949
15911
|
if (needFocusSegmentId && needFocusSegmentId !== prevSegmentId) docSelectionRenderService.setSegment(needFocusSegmentId);
|
|
14950
15912
|
commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
14951
15913
|
unitId,
|
|
14952
|
-
headerFooterProps: { [type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE }
|
|
15914
|
+
headerFooterProps: { [type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE },
|
|
15915
|
+
sectionId: sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionId
|
|
14953
15916
|
});
|
|
14954
15917
|
}
|
|
14955
15918
|
layoutService.focus();
|
|
14956
15919
|
};
|
|
14957
15920
|
const handleMarginChange = async (val, type) => {
|
|
15921
|
+
var _getCurrentSectionCon2;
|
|
14958
15922
|
setOptions((prev) => ({
|
|
14959
15923
|
...prev,
|
|
14960
15924
|
[type]: val
|
|
14961
15925
|
}));
|
|
14962
15926
|
await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
14963
15927
|
unitId,
|
|
14964
|
-
headerFooterProps: { [type]: val }
|
|
15928
|
+
headerFooterProps: { [type]: val },
|
|
15929
|
+
sectionId: (_getCurrentSectionCon2 = getCurrentSectionContext()) === null || _getCurrentSectionCon2 === void 0 ? void 0 : _getCurrentSectionCon2.sectionId
|
|
14965
15930
|
});
|
|
14966
15931
|
docSelectionRenderService.removeAllRanges();
|
|
14967
15932
|
docSelectionRenderService.blur();
|
|
@@ -14969,22 +15934,37 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
14969
15934
|
const closeHeaderFooter = () => {
|
|
14970
15935
|
commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId });
|
|
14971
15936
|
};
|
|
14972
|
-
|
|
14973
|
-
|
|
14974
|
-
const
|
|
14975
|
-
if (
|
|
14976
|
-
|
|
14977
|
-
|
|
14978
|
-
|
|
14979
|
-
|
|
14980
|
-
|
|
14981
|
-
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
15937
|
+
const handleLinkToPreviousChange = async (linked) => {
|
|
15938
|
+
var _renderManagerService4;
|
|
15939
|
+
const context = getCurrentSectionContext();
|
|
15940
|
+
if (!(context === null || context === void 0 ? void 0 : context.sectionId) || context.sectionIndex <= 0 || !docDataModel) return;
|
|
15941
|
+
const kind = ((_renderManagerService4 = renderManagerService.getRenderById(unitId)) === null || _renderManagerService4 === void 0 || (_renderManagerService4 = _renderManagerService4.with(DocSkeletonManagerService)) === null || _renderManagerService4 === void 0 || (_renderManagerService4 = _renderManagerService4.getViewModel()) === null || _renderManagerService4 === void 0 ? void 0 : _renderManagerService4.getEditArea()) === DocumentEditArea.FOOTER ? "footer" : "header";
|
|
15942
|
+
const currentVariant = getHeaderFooterVariant(context.config, docSelectionRenderService.getSegmentPage(), context.page);
|
|
15943
|
+
const key = getSectionHeaderFooterReferenceKey(kind, currentVariant);
|
|
15944
|
+
const segmentId = generateRandomId(6);
|
|
15945
|
+
const previousSegmentId = resolveSectionHeaderFooterReference(docDataModel.getDocumentStyle(), context.sections, context.sectionIndex - 1, key).segmentId;
|
|
15946
|
+
if (!await commandService.executeCommand(SetSectionHeaderFooterLinkCommand.id, {
|
|
15947
|
+
unitId,
|
|
15948
|
+
sectionId: context.sectionId,
|
|
15949
|
+
kind,
|
|
15950
|
+
variant: currentVariant,
|
|
15951
|
+
linkedToPrevious: linked,
|
|
15952
|
+
...linked ? {} : { segmentId }
|
|
15953
|
+
})) return;
|
|
15954
|
+
setLinkedToPrevious(linked);
|
|
15955
|
+
docSelectionRenderService.setSegment(linked ? previousSegmentId !== null && previousSegmentId !== void 0 ? previousSegmentId : "" : segmentId);
|
|
15956
|
+
layoutService.focus();
|
|
15957
|
+
};
|
|
14985
15958
|
return /* @__PURE__ */ jsxs("div", {
|
|
14986
15959
|
className: "univer-grid univer-gap-4",
|
|
14987
15960
|
children: [
|
|
15961
|
+
canLinkToPrevious && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
15962
|
+
checked: linkedToPrevious,
|
|
15963
|
+
onChange: (val) => {
|
|
15964
|
+
handleLinkToPreviousChange(val);
|
|
15965
|
+
},
|
|
15966
|
+
children: localeService.t("docs-ui.headerFooter.linkToPrevious")
|
|
15967
|
+
}) }),
|
|
14988
15968
|
/* @__PURE__ */ jsxs("div", {
|
|
14989
15969
|
className: "univer-grid univer-gap-2",
|
|
14990
15970
|
children: [/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
@@ -15032,7 +16012,14 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
15032
16012
|
})
|
|
15033
16013
|
]
|
|
15034
16014
|
});
|
|
15035
|
-
}
|
|
16015
|
+
}
|
|
16016
|
+
function getHeaderFooterVariant(documentStyle, pageIndex, page) {
|
|
16017
|
+
const isFirstPage = page ? page.pageNumber === page.pageNumberStart : pageIndex === 0;
|
|
16018
|
+
const isEvenPage = page ? page.pageNumber % 2 === 0 : pageIndex % 2 === 1;
|
|
16019
|
+
if (documentStyle.useFirstPageHeaderFooter === BooleanNumber.TRUE && isFirstPage) return "first";
|
|
16020
|
+
if (documentStyle.evenAndOddHeaders === BooleanNumber.TRUE && isEvenPage) return "even";
|
|
16021
|
+
return "default";
|
|
16022
|
+
}
|
|
15036
16023
|
|
|
15037
16024
|
//#endregion
|
|
15038
16025
|
//#region src/views/header-footer/panel/DocHeaderFooterPanel.tsx
|
|
@@ -15127,12 +16114,14 @@ function TextColorSwatchIcon({ className, style, onClick, color }) {
|
|
|
15127
16114
|
stroke: "currentColor",
|
|
15128
16115
|
strokeOpacity: .16
|
|
15129
16116
|
}), /* @__PURE__ */ jsx("text", {
|
|
15130
|
-
x:
|
|
16117
|
+
x: 12,
|
|
15131
16118
|
y: 16.5,
|
|
16119
|
+
direction: "ltr",
|
|
15132
16120
|
fontFamily: "Arial, sans-serif",
|
|
15133
16121
|
fontSize: 12,
|
|
15134
16122
|
fontWeight: 700,
|
|
15135
16123
|
fill: color,
|
|
16124
|
+
textAnchor: "middle",
|
|
15136
16125
|
children: "A"
|
|
15137
16126
|
})]
|
|
15138
16127
|
});
|
|
@@ -15219,6 +16208,26 @@ const DocParagraphBackgroundColorSwatchIcon13 = createBackgroundColorSwatchIcon(
|
|
|
15219
16208
|
const DocParagraphBackgroundColorSwatchIcon14 = createBackgroundColorSwatchIcon(14);
|
|
15220
16209
|
const DocParagraphBackgroundColorSwatchIcon15 = createBackgroundColorSwatchIcon(15);
|
|
15221
16210
|
|
|
16211
|
+
//#endregion
|
|
16212
|
+
//#region src/views/paragraph-menu/component-keys.ts
|
|
16213
|
+
/**
|
|
16214
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
16215
|
+
*
|
|
16216
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16217
|
+
* you may not use this file except in compliance with the License.
|
|
16218
|
+
* You may obtain a copy of the License at
|
|
16219
|
+
*
|
|
16220
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16221
|
+
*
|
|
16222
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16223
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16224
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16225
|
+
* See the License for the specific language governing permissions and
|
|
16226
|
+
* limitations under the License.
|
|
16227
|
+
*/
|
|
16228
|
+
const DOC_PARAGRAPH_MENU_COMPONENT_KEY = "doc.paragraph.menu";
|
|
16229
|
+
const DOC_TABLE_BLOCK_MENU_COMPONENT_KEY = "doc.table-block.menu";
|
|
16230
|
+
|
|
15222
16231
|
//#endregion
|
|
15223
16232
|
//#region src/views/paragraph-setting/line-spacing.ts
|
|
15224
16233
|
const AUTO_LINE_SPACING_CONFIG = {
|
|
@@ -15237,22 +16246,20 @@ function round(value, digits) {
|
|
|
15237
16246
|
function clamp(value, min, max) {
|
|
15238
16247
|
return Math.min(max, Math.max(min, value));
|
|
15239
16248
|
}
|
|
15240
|
-
|
|
15241
|
-
|
|
15242
|
-
|
|
15243
|
-
|
|
15244
|
-
|
|
15245
|
-
|
|
15246
|
-
|
|
15247
|
-
|
|
15248
|
-
|
|
15249
|
-
|
|
15250
|
-
|
|
15251
|
-
|
|
15252
|
-
|
|
15253
|
-
|
|
15254
|
-
];
|
|
15255
|
-
}
|
|
16249
|
+
const LINE_SPACING_RULE_OPTIONS = [
|
|
16250
|
+
{
|
|
16251
|
+
label: "docs-ui.doc.paragraphSetting.multiSpace",
|
|
16252
|
+
value: `${SpacingRule.AUTO}`
|
|
16253
|
+
},
|
|
16254
|
+
{
|
|
16255
|
+
label: "docs-ui.doc.paragraphSetting.atLeast",
|
|
16256
|
+
value: `${SpacingRule.AT_LEAST}`
|
|
16257
|
+
},
|
|
16258
|
+
{
|
|
16259
|
+
label: "docs-ui.doc.paragraphSetting.exactly",
|
|
16260
|
+
value: `${SpacingRule.EXACT}`
|
|
16261
|
+
}
|
|
16262
|
+
];
|
|
15256
16263
|
function getLineSpacingInputConfig(spacingRule) {
|
|
15257
16264
|
return spacingRule === SpacingRule.AUTO ? AUTO_LINE_SPACING_CONFIG : FIXED_LINE_SPACING_CONFIG;
|
|
15258
16265
|
}
|
|
@@ -15290,6 +16297,21 @@ function convertLineSpacingForRuleChange(currentStoredValue, currentRule, nextRu
|
|
|
15290
16297
|
|
|
15291
16298
|
//#endregion
|
|
15292
16299
|
//#region src/views/paragraph-setting/hook/utils.ts
|
|
16300
|
+
const PARAGRAPH_LAYOUT_BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
16301
|
+
DocumentBlockRangeType.CALLOUT,
|
|
16302
|
+
DocumentBlockRangeType.CODE,
|
|
16303
|
+
DocumentBlockRangeType.QUOTE
|
|
16304
|
+
]);
|
|
16305
|
+
function resolveParagraphsForSettingPanel(paragraphs, body, documentStyle) {
|
|
16306
|
+
return paragraphs.map((paragraph) => {
|
|
16307
|
+
var _body$blockRanges$som, _body$blockRanges;
|
|
16308
|
+
const hasLayoutBlockRange = (_body$blockRanges$som = (_body$blockRanges = body.blockRanges) === null || _body$blockRanges === void 0 ? void 0 : _body$blockRanges.some((range) => PARAGRAPH_LAYOUT_BLOCK_TYPES.has(range.blockType) && paragraph.startIndex > range.startIndex && paragraph.startIndex < range.endIndex)) !== null && _body$blockRanges$som !== void 0 ? _body$blockRanges$som : false;
|
|
16309
|
+
return {
|
|
16310
|
+
...paragraph,
|
|
16311
|
+
paragraphStyle: resolveDocumentParagraphStyle(documentStyle, paragraph.paragraphStyle, { excludeDocumentOuterSpacing: hasLayoutBlockRange })
|
|
16312
|
+
};
|
|
16313
|
+
});
|
|
16314
|
+
}
|
|
15293
16315
|
const useDocRanges = () => {
|
|
15294
16316
|
const docSelectionManagerService = useDependency(DocSelectionManagerService);
|
|
15295
16317
|
const docParagraphSettingController = useDependency(DocParagraphSettingController);
|
|
@@ -15300,15 +16322,17 @@ const useDocRanges = () => {
|
|
|
15300
16322
|
return docRanges;
|
|
15301
16323
|
};
|
|
15302
16324
|
const useCurrentParagraph = () => {
|
|
15303
|
-
var
|
|
16325
|
+
var _body$paragraphs, _body$dataStream, _BuildTextUtils$range;
|
|
15304
16326
|
const docDataModel = useDependency(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
15305
16327
|
const docRanges = useDocRanges();
|
|
15306
16328
|
if (!docDataModel || docRanges.length === 0) return [];
|
|
15307
16329
|
const segmentId = docRanges[0].segmentId;
|
|
15308
16330
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
15309
|
-
const
|
|
15310
|
-
const
|
|
15311
|
-
|
|
16331
|
+
const body = segment === null || segment === void 0 ? void 0 : segment.getBody();
|
|
16332
|
+
const paragraphs = (_body$paragraphs = body === null || body === void 0 ? void 0 : body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : [];
|
|
16333
|
+
const dataStream = (_body$dataStream = body === null || body === void 0 ? void 0 : body.dataStream) !== null && _body$dataStream !== void 0 ? _body$dataStream : "";
|
|
16334
|
+
const currentParagraphs = (_BuildTextUtils$range = BuildTextUtils.range.getParagraphsInRanges(docRanges, paragraphs, dataStream)) !== null && _BuildTextUtils$range !== void 0 ? _BuildTextUtils$range : [];
|
|
16335
|
+
return body == null ? currentParagraphs : resolveParagraphsForSettingPanel(currentParagraphs, body, docDataModel.getDocumentStyle());
|
|
15312
16336
|
};
|
|
15313
16337
|
const useFirstParagraphHorizontalAlign = (paragraph, defaultValue) => {
|
|
15314
16338
|
const commandService = useDependency(ICommandService);
|
|
@@ -15474,13 +16498,36 @@ const useFirstParagraphLineSpacing = (paragraph) => {
|
|
|
15474
16498
|
|
|
15475
16499
|
//#endregion
|
|
15476
16500
|
//#region src/views/paragraph-setting/Setting.tsx
|
|
16501
|
+
const ALIGNMENT_OPTIONS = [
|
|
16502
|
+
{
|
|
16503
|
+
label: "docs-ui.toolbar.alignLeft",
|
|
16504
|
+
value: String(HorizontalAlign.LEFT),
|
|
16505
|
+
icon: /* @__PURE__ */ jsx(LeftJustifyingIcon, {})
|
|
16506
|
+
},
|
|
16507
|
+
{
|
|
16508
|
+
label: "docs-ui.toolbar.alignCenter",
|
|
16509
|
+
value: String(HorizontalAlign.CENTER),
|
|
16510
|
+
icon: /* @__PURE__ */ jsx(HorizontallyIcon, {})
|
|
16511
|
+
},
|
|
16512
|
+
{
|
|
16513
|
+
label: "docs-ui.toolbar.alignRight",
|
|
16514
|
+
value: String(HorizontalAlign.RIGHT),
|
|
16515
|
+
icon: /* @__PURE__ */ jsx(RightJustifyingIcon, {})
|
|
16516
|
+
},
|
|
16517
|
+
{
|
|
16518
|
+
label: "docs-ui.toolbar.alignJustify",
|
|
16519
|
+
value: String(HorizontalAlign.JUSTIFIED),
|
|
16520
|
+
icon: /* @__PURE__ */ jsx(AlignTextBothIcon, {})
|
|
16521
|
+
}
|
|
16522
|
+
];
|
|
15477
16523
|
const ParagraphSettingSection = (props) => {
|
|
15478
|
-
const {
|
|
16524
|
+
const { titleKey, children, first = false } = props;
|
|
16525
|
+
const localeService = useDependency(LocaleService);
|
|
15479
16526
|
return /* @__PURE__ */ jsxs("section", {
|
|
15480
16527
|
className: clsx(!first && "univer-mt-5"),
|
|
15481
16528
|
children: [/* @__PURE__ */ jsx("div", {
|
|
15482
16529
|
className: "univer-text-sm univer-font-medium univer-leading-5",
|
|
15483
|
-
children:
|
|
16530
|
+
children: localeService.t(titleKey)
|
|
15484
16531
|
}), /* @__PURE__ */ jsx("div", {
|
|
15485
16532
|
className: "univer-mt-3",
|
|
15486
16533
|
children
|
|
@@ -15488,13 +16535,13 @@ const ParagraphSettingSection = (props) => {
|
|
|
15488
16535
|
});
|
|
15489
16536
|
};
|
|
15490
16537
|
const ParagraphSettingRow = (props) => {
|
|
15491
|
-
const {
|
|
16538
|
+
const { labelKey, unit, children } = props;
|
|
15492
16539
|
return /* @__PURE__ */ jsxs("div", {
|
|
15493
16540
|
className: "univer-grid univer-min-h-8 univer-items-center univer-gap-3",
|
|
15494
16541
|
style: { gridTemplateColumns: "minmax(0, 1fr) minmax(160px, 180px)" },
|
|
15495
|
-
children: [/* @__PURE__ */
|
|
16542
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
15496
16543
|
className: "univer-min-w-0 univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-text-gray-100",
|
|
15497
|
-
children:
|
|
16544
|
+
children: [useDependency(LocaleService).t(labelKey), unit]
|
|
15498
16545
|
}), /* @__PURE__ */ jsx("div", {
|
|
15499
16546
|
className: "univer-w-full univer-min-w-0",
|
|
15500
16547
|
children
|
|
@@ -15524,30 +16571,8 @@ const AutoFocusInputNumber = (props) => {
|
|
|
15524
16571
|
};
|
|
15525
16572
|
function ParagraphSetting() {
|
|
15526
16573
|
const localeService = useDependency(LocaleService);
|
|
15527
|
-
const alignmentOptions = useMemo(() => [
|
|
15528
|
-
{
|
|
15529
|
-
label: localeService.t("docs-ui.toolbar.alignLeft"),
|
|
15530
|
-
value: String(HorizontalAlign.LEFT),
|
|
15531
|
-
icon: /* @__PURE__ */ jsx(LeftJustifyingIcon, {})
|
|
15532
|
-
},
|
|
15533
|
-
{
|
|
15534
|
-
label: localeService.t("docs-ui.toolbar.alignCenter"),
|
|
15535
|
-
value: String(HorizontalAlign.CENTER),
|
|
15536
|
-
icon: /* @__PURE__ */ jsx(HorizontallyIcon, {})
|
|
15537
|
-
},
|
|
15538
|
-
{
|
|
15539
|
-
label: localeService.t("docs-ui.toolbar.alignRight"),
|
|
15540
|
-
value: String(HorizontalAlign.RIGHT),
|
|
15541
|
-
icon: /* @__PURE__ */ jsx(RightJustifyingIcon, {})
|
|
15542
|
-
},
|
|
15543
|
-
{
|
|
15544
|
-
label: localeService.t("docs-ui.toolbar.alignJustify"),
|
|
15545
|
-
value: String(HorizontalAlign.JUSTIFIED),
|
|
15546
|
-
icon: /* @__PURE__ */ jsx(AlignTextBothIcon, {})
|
|
15547
|
-
}
|
|
15548
|
-
], []);
|
|
15549
16574
|
const currentParagraph = useCurrentParagraph();
|
|
15550
|
-
const [horizontalAlignValue, setHorizontalAlign] = useFirstParagraphHorizontalAlign(currentParagraph,
|
|
16575
|
+
const [horizontalAlignValue, setHorizontalAlign] = useFirstParagraphHorizontalAlign(currentParagraph, ALIGNMENT_OPTIONS[0].value);
|
|
15551
16576
|
const [indentStart, setIndentStart] = useFirstParagraphIndentStart(currentParagraph);
|
|
15552
16577
|
const [indentEnd, setIndentEnd] = useFirstParagraphIndentEnd(currentParagraph);
|
|
15553
16578
|
const [indentFirstLine, setIndentFirstLine] = useFirstParagraphIndentFirstLine(currentParagraph);
|
|
@@ -15556,18 +16581,21 @@ function ParagraphSetting() {
|
|
|
15556
16581
|
const [spaceBelow, setSpaceBelow] = useFirstParagraphSpaceBelow(currentParagraph);
|
|
15557
16582
|
const { lineSpacing: [lineSpacing, setLineSpacing], spacingRule: [spacingRule, setSpacingRule] } = useFirstParagraphLineSpacing(currentParagraph);
|
|
15558
16583
|
const lineSpaceConfig = useMemo(() => getLineSpacingInputConfig(spacingRule), [spacingRule]);
|
|
15559
|
-
const lineSpacingOptions =
|
|
16584
|
+
const lineSpacingOptions = LINE_SPACING_RULE_OPTIONS.map((option) => ({
|
|
16585
|
+
...option,
|
|
16586
|
+
label: localeService.t(option.label)
|
|
16587
|
+
}));
|
|
15560
16588
|
return /* @__PURE__ */ jsxs("div", {
|
|
15561
16589
|
className: "univer-box-border univer-w-full",
|
|
15562
16590
|
children: [
|
|
15563
16591
|
/* @__PURE__ */ jsx(ParagraphSettingSection, {
|
|
15564
|
-
|
|
16592
|
+
titleKey: "docs-ui.doc.paragraphSetting.alignment",
|
|
15565
16593
|
first: true,
|
|
15566
16594
|
children: /* @__PURE__ */ jsx("div", {
|
|
15567
16595
|
className: clsx("univer-flex univer-grid-cols-4 univer-items-center univer-justify-around univer-gap-2 univer-rounded-lg univer-bg-white univer-p-1 dark:!univer-bg-gray-900", borderClassName),
|
|
15568
|
-
children:
|
|
16596
|
+
children: ALIGNMENT_OPTIONS.map((item) => {
|
|
15569
16597
|
return /* @__PURE__ */ jsx(Tooltip, {
|
|
15570
|
-
title: item.label,
|
|
16598
|
+
title: localeService.t(item.label),
|
|
15571
16599
|
placement: "bottom",
|
|
15572
16600
|
children: /* @__PURE__ */ jsx("span", {
|
|
15573
16601
|
className: "univer-flex univer-w-full univer-items-center univer-justify-center",
|
|
@@ -15587,33 +16615,37 @@ function ParagraphSetting() {
|
|
|
15587
16615
|
})
|
|
15588
16616
|
}),
|
|
15589
16617
|
/* @__PURE__ */ jsx(ParagraphSettingSection, {
|
|
15590
|
-
|
|
16618
|
+
titleKey: "docs-ui.doc.paragraphSetting.indentation",
|
|
15591
16619
|
children: /* @__PURE__ */ jsxs("div", {
|
|
15592
16620
|
className: "univer-grid univer-gap-3",
|
|
15593
16621
|
children: [
|
|
15594
16622
|
/* @__PURE__ */ jsx(ParagraphSettingRow, {
|
|
15595
|
-
|
|
16623
|
+
labelKey: "docs-ui.doc.paragraphSetting.left",
|
|
16624
|
+
unit: "(px)",
|
|
15596
16625
|
children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
|
|
15597
16626
|
value: indentStart,
|
|
15598
16627
|
onChange: (v) => setIndentStart(v !== null && v !== void 0 ? v : 0)
|
|
15599
16628
|
})
|
|
15600
16629
|
}),
|
|
15601
16630
|
/* @__PURE__ */ jsx(ParagraphSettingRow, {
|
|
15602
|
-
|
|
16631
|
+
labelKey: "docs-ui.doc.paragraphSetting.right",
|
|
16632
|
+
unit: "(px)",
|
|
15603
16633
|
children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
|
|
15604
16634
|
value: indentEnd,
|
|
15605
16635
|
onChange: (v) => setIndentEnd(v !== null && v !== void 0 ? v : 0)
|
|
15606
16636
|
})
|
|
15607
16637
|
}),
|
|
15608
16638
|
/* @__PURE__ */ jsx(ParagraphSettingRow, {
|
|
15609
|
-
|
|
16639
|
+
labelKey: "docs-ui.doc.paragraphSetting.firstLine",
|
|
16640
|
+
unit: "(px)",
|
|
15610
16641
|
children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
|
|
15611
16642
|
value: indentFirstLine,
|
|
15612
16643
|
onChange: (v) => setIndentFirstLine(v !== null && v !== void 0 ? v : 0)
|
|
15613
16644
|
})
|
|
15614
16645
|
}),
|
|
15615
16646
|
/* @__PURE__ */ jsx(ParagraphSettingRow, {
|
|
15616
|
-
|
|
16647
|
+
labelKey: "docs-ui.doc.paragraphSetting.hanging",
|
|
16648
|
+
unit: "(px)",
|
|
15617
16649
|
children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
|
|
15618
16650
|
value: hanging,
|
|
15619
16651
|
onChange: (v) => setHanging(v !== null && v !== void 0 ? v : 0)
|
|
@@ -15623,26 +16655,28 @@ function ParagraphSetting() {
|
|
|
15623
16655
|
})
|
|
15624
16656
|
}),
|
|
15625
16657
|
/* @__PURE__ */ jsx(ParagraphSettingSection, {
|
|
15626
|
-
|
|
16658
|
+
titleKey: "docs-ui.doc.paragraphSetting.spacing",
|
|
15627
16659
|
children: /* @__PURE__ */ jsxs("div", {
|
|
15628
16660
|
className: "univer-grid univer-gap-3",
|
|
15629
16661
|
children: [
|
|
15630
16662
|
/* @__PURE__ */ jsx(ParagraphSettingRow, {
|
|
15631
|
-
|
|
16663
|
+
labelKey: "docs-ui.doc.paragraphSetting.before",
|
|
16664
|
+
unit: "(px)",
|
|
15632
16665
|
children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
|
|
15633
16666
|
value: spaceAbove,
|
|
15634
16667
|
onChange: (v) => setSpaceAbove(v !== null && v !== void 0 ? v : 0)
|
|
15635
16668
|
})
|
|
15636
16669
|
}),
|
|
15637
16670
|
/* @__PURE__ */ jsx(ParagraphSettingRow, {
|
|
15638
|
-
|
|
16671
|
+
labelKey: "docs-ui.doc.paragraphSetting.after",
|
|
16672
|
+
unit: "(px)",
|
|
15639
16673
|
children: /* @__PURE__ */ jsx(AutoFocusInputNumber, {
|
|
15640
16674
|
value: spaceBelow,
|
|
15641
16675
|
onChange: (v) => setSpaceBelow(v !== null && v !== void 0 ? v : 0)
|
|
15642
16676
|
})
|
|
15643
16677
|
}),
|
|
15644
16678
|
/* @__PURE__ */ jsx(ParagraphSettingRow, {
|
|
15645
|
-
|
|
16679
|
+
labelKey: "docs-ui.doc.paragraphSetting.lineSpace",
|
|
15646
16680
|
children: /* @__PURE__ */ jsxs("div", {
|
|
15647
16681
|
className: "univer-flex univer-w-full univer-flex-col univer-gap-2",
|
|
15648
16682
|
children: [/* @__PURE__ */ jsx(Select, {
|
|
@@ -15697,26 +16731,6 @@ function ParagraphSettingIndex() {
|
|
|
15697
16731
|
return /* @__PURE__ */ jsx(ParagraphSetting, {}, key);
|
|
15698
16732
|
}
|
|
15699
16733
|
|
|
15700
|
-
//#endregion
|
|
15701
|
-
//#region src/views/paragraph-menu/component-keys.ts
|
|
15702
|
-
/**
|
|
15703
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
15704
|
-
*
|
|
15705
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15706
|
-
* you may not use this file except in compliance with the License.
|
|
15707
|
-
* You may obtain a copy of the License at
|
|
15708
|
-
*
|
|
15709
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15710
|
-
*
|
|
15711
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15712
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15713
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15714
|
-
* See the License for the specific language governing permissions and
|
|
15715
|
-
* limitations under the License.
|
|
15716
|
-
*/
|
|
15717
|
-
const DOC_PARAGRAPH_MENU_COMPONENT_KEY = "doc.paragraph.menu";
|
|
15718
|
-
const DOC_TABLE_BLOCK_MENU_COMPONENT_KEY = "doc.table-block.menu";
|
|
15719
|
-
|
|
15720
16734
|
//#endregion
|
|
15721
16735
|
//#region src/views/float-toolbar/FloatToolbar.tsx
|
|
15722
16736
|
const DEFAULT_AVALIABLE_MENUS = [
|
|
@@ -15807,6 +16821,9 @@ let DocFloatMenuService = class DocFloatMenuService extends Disposable {
|
|
|
15807
16821
|
get floatMenu() {
|
|
15808
16822
|
return this._floatMenu;
|
|
15809
16823
|
}
|
|
16824
|
+
hideFloatMenu() {
|
|
16825
|
+
this._hideFloatMenu();
|
|
16826
|
+
}
|
|
15810
16827
|
_registerFloatMenu() {
|
|
15811
16828
|
this.disposeWithMe(this._componentManager.register(FLOAT_MENU_COMPONENT_KEY, FloatToolbar));
|
|
15812
16829
|
}
|
|
@@ -16462,15 +17479,10 @@ function isParagraphInTable(documentDataModel, paragraphStart) {
|
|
|
16462
17479
|
return ((_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.tables) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : []).some((table) => paragraphStart > table.startIndex && paragraphStart < table.endIndex);
|
|
16463
17480
|
}
|
|
16464
17481
|
function getParagraphMoveRange(documentDataModel, paragraph, cellRange) {
|
|
16465
|
-
|
|
16466
|
-
const
|
|
16467
|
-
const index = paragraphs.findIndex((item) => item.startIndex === paragraph.startIndex);
|
|
16468
|
-
const previousParagraph = index > 0 ? paragraphs.slice(0, index).reverse().find((item) => {
|
|
16469
|
-
if (!cellRange) return true;
|
|
16470
|
-
return item.startIndex > cellRange.startOffset && item.startIndex < cellRange.endOffset;
|
|
16471
|
-
}) : null;
|
|
17482
|
+
const body = documentDataModel.getBody();
|
|
17483
|
+
const paragraphStartOffset = body ? getParagraphContentStartOffset(body, paragraph) : 0;
|
|
16472
17484
|
return {
|
|
16473
|
-
startOffset:
|
|
17485
|
+
startOffset: cellRange ? Math.max(paragraphStartOffset, cellRange.startOffset + 1) : paragraphStartOffset,
|
|
16474
17486
|
endOffset: paragraph.startIndex + 1
|
|
16475
17487
|
};
|
|
16476
17488
|
}
|
|
@@ -16524,8 +17536,8 @@ function unionRects(rects) {
|
|
|
16524
17536
|
}));
|
|
16525
17537
|
}
|
|
16526
17538
|
function getParagraphBlockRange(documentDataModel, paragraph) {
|
|
16527
|
-
var _documentDataModel$
|
|
16528
|
-
return ((_documentDataModel$
|
|
17539
|
+
var _documentDataModel$ge3, _documentDataModel$ge4;
|
|
17540
|
+
return ((_documentDataModel$ge3 = (_documentDataModel$ge4 = documentDataModel.getBody()) === null || _documentDataModel$ge4 === void 0 ? void 0 : _documentDataModel$ge4.blockRanges) !== null && _documentDataModel$ge3 !== void 0 ? _documentDataModel$ge3 : []).find((range) => Math.max(paragraph.paragraphStart, range.startIndex) <= Math.min(paragraph.paragraphEnd, range.endIndex));
|
|
16529
17541
|
}
|
|
16530
17542
|
function getBlockRangeAnchorRect(docEventManagerService, blockRange, fallbackParagraph) {
|
|
16531
17543
|
var _bounds$0$firstLine, _bounds$;
|
|
@@ -16544,8 +17556,12 @@ function getBlockRangeAnchorRect(docEventManagerService, blockRange, fallbackPar
|
|
|
16544
17556
|
|
|
16545
17557
|
//#endregion
|
|
16546
17558
|
//#region src/views/ParagraphMenu.tsx
|
|
16547
|
-
function getParagraphMenuPopupDirection(anchorLeft, menuWidth = 212, viewportPadding = 8) {
|
|
16548
|
-
|
|
17559
|
+
function getParagraphMenuPopupDirection(anchorLeft, menuWidth = 212, viewportPadding = 8, options = {}) {
|
|
17560
|
+
const { anchorRight = anchorLeft, direction = "ltr", viewportWidth = Number.POSITIVE_INFINITY } = options;
|
|
17561
|
+
const hasLeftSpace = anchorLeft - menuWidth >= viewportPadding;
|
|
17562
|
+
const hasRightSpace = anchorRight + menuWidth + viewportPadding <= viewportWidth;
|
|
17563
|
+
if (direction === "rtl") return hasRightSpace || !hasLeftSpace ? "right" : "left";
|
|
17564
|
+
return hasLeftSpace || !hasRightSpace ? "left" : "right";
|
|
16549
17565
|
}
|
|
16550
17566
|
const PARAGRAPH_MENU_HOVER_OPEN_DELAY = 800;
|
|
16551
17567
|
const PARAGRAPH_MENU_HOVER_HIDE_DELAY = 240;
|
|
@@ -16888,19 +17904,75 @@ function unwrapBlockRangeBody(documentBody, blockRange) {
|
|
|
16888
17904
|
}
|
|
16889
17905
|
};
|
|
16890
17906
|
}
|
|
16891
|
-
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
|
|
17907
|
+
const UNWRAP_BLOCK_BODY_PATCH_KEYS = [
|
|
17908
|
+
"paragraphs",
|
|
17909
|
+
"sectionBreaks",
|
|
17910
|
+
"textRuns",
|
|
17911
|
+
"customRanges",
|
|
17912
|
+
"customDecorations",
|
|
17913
|
+
"customBlocks",
|
|
17914
|
+
"tables",
|
|
17915
|
+
"columnGroups",
|
|
17916
|
+
"blockRanges"
|
|
17917
|
+
];
|
|
17918
|
+
function buildUnwrapBlockRangeActions(previousBody, nextBody, blockRange) {
|
|
17919
|
+
const endTokenOffset = getEndTokenOffset(previousBody, blockRange);
|
|
17920
|
+
const textX = new TextX();
|
|
17921
|
+
textX.retain(blockRange.startIndex);
|
|
17922
|
+
textX.delete(1);
|
|
17923
|
+
textX.retain(Math.max(0, endTokenOffset - blockRange.startIndex - 1));
|
|
17924
|
+
textX.delete(1);
|
|
17925
|
+
const textAction = JSONX.getInstance().editOp(textX.serialize(), ["body"]);
|
|
17926
|
+
const intermediateBody = Tools.deepClone(previousBody);
|
|
17927
|
+
TextX.apply(intermediateBody, textX.serialize());
|
|
17928
|
+
const rawActions = [textAction];
|
|
17929
|
+
collectUnwrapBlockBodyPatchActions(intermediateBody, nextBody, rawActions);
|
|
17930
|
+
return rawActions.reduce((acc, action) => JSONX.compose(acc, action), null);
|
|
17931
|
+
}
|
|
17932
|
+
function collectUnwrapBlockBodyPatchActions(previousBody, nextBody, actions) {
|
|
17933
|
+
for (const key of UNWRAP_BLOCK_BODY_PATCH_KEYS) collectUnwrapPatchActions(JSONX.getInstance(), ["body", key], previousBody[key], nextBody[key], actions);
|
|
17934
|
+
}
|
|
17935
|
+
function collectUnwrapPatchActions(jsonX, path, oldValue, newValue, actions) {
|
|
17936
|
+
if (isEmptyArrayEquivalent(oldValue, newValue) || Tools.diffValue(oldValue, newValue)) return;
|
|
17937
|
+
if (oldValue == null) {
|
|
17938
|
+
actions.push(jsonX.insertOp(path, newValue));
|
|
17939
|
+
return;
|
|
17940
|
+
}
|
|
17941
|
+
if (newValue == null) {
|
|
17942
|
+
actions.push(jsonX.removeOp(path, oldValue));
|
|
17943
|
+
return;
|
|
17944
|
+
}
|
|
17945
|
+
if (Array.isArray(oldValue) && Array.isArray(newValue)) {
|
|
17946
|
+
collectUnwrapArrayPatchActions(jsonX, path, oldValue, newValue, actions);
|
|
17947
|
+
return;
|
|
17948
|
+
}
|
|
17949
|
+
if (isPlainObject(oldValue) && isPlainObject(newValue)) {
|
|
17950
|
+
(/* @__PURE__ */ new Set([...Object.keys(oldValue), ...Object.keys(newValue)])).forEach((key) => collectUnwrapPatchActions(jsonX, [...path, key], oldValue[key], newValue[key], actions));
|
|
17951
|
+
return;
|
|
17952
|
+
}
|
|
17953
|
+
actions.push(jsonX.replaceOp(path, oldValue, newValue));
|
|
17954
|
+
}
|
|
17955
|
+
function collectUnwrapArrayPatchActions(jsonX, path, oldItems, newItems, actions) {
|
|
17956
|
+
if (oldItems.length === newItems.length) {
|
|
17957
|
+
oldItems.forEach((item, index) => collectUnwrapPatchActions(jsonX, [...path, index], item, newItems[index], actions));
|
|
17958
|
+
return;
|
|
17959
|
+
}
|
|
17960
|
+
let prefix = 0;
|
|
17961
|
+
while (prefix < oldItems.length && prefix < newItems.length && Tools.diffValue(oldItems[prefix], newItems[prefix])) prefix++;
|
|
17962
|
+
let oldSuffix = oldItems.length - 1;
|
|
17963
|
+
let newSuffix = newItems.length - 1;
|
|
17964
|
+
while (oldSuffix >= prefix && newSuffix >= prefix && Tools.diffValue(oldItems[oldSuffix], newItems[newSuffix])) {
|
|
17965
|
+
oldSuffix--;
|
|
17966
|
+
newSuffix--;
|
|
17967
|
+
}
|
|
17968
|
+
for (let index = oldSuffix; index >= prefix; index--) actions.push(jsonX.removeOp([...path, index], oldItems[index]));
|
|
17969
|
+
for (let index = prefix; index <= newSuffix; index++) actions.push(jsonX.insertOp([...path, index], newItems[index]));
|
|
17970
|
+
}
|
|
17971
|
+
function isPlainObject(value) {
|
|
17972
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
17973
|
+
}
|
|
17974
|
+
function isEmptyArrayEquivalent(oldValue, newValue) {
|
|
17975
|
+
return oldValue == null && Array.isArray(newValue) && newValue.length === 0 || newValue == null && Array.isArray(oldValue) && oldValue.length === 0;
|
|
16904
17976
|
}
|
|
16905
17977
|
function getTargetSelectionRange(target, paragraph) {
|
|
16906
17978
|
if (!target) return getParagraphMenuTargetRange(paragraph);
|
|
@@ -16953,7 +18025,9 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
16953
18025
|
const openMenuRef = useRef(() => void 0);
|
|
16954
18026
|
const hoverOpenSchedulerRef = useRef(createParagraphMenuHoverOpenScheduler(() => openMenuRef.current()));
|
|
16955
18027
|
const commandService = useDependency(ICommandService);
|
|
18028
|
+
const localeService = useDependency(LocaleService);
|
|
16956
18029
|
const docSelectionManagerService = useDependency(DocSelectionManagerService);
|
|
18030
|
+
const direction = useObservable(localeService.direction$, "ltr");
|
|
16957
18031
|
const docClipboardService = useDependency(IDocClipboardService);
|
|
16958
18032
|
const docContentInsertService = useDependency(DocContentInsertService);
|
|
16959
18033
|
const docBlockMoveValidatorService = useDependency(DocBlockMoveValidatorService);
|
|
@@ -17001,13 +18075,18 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
17001
18075
|
bottom: 0
|
|
17002
18076
|
}), []);
|
|
17003
18077
|
const updateAnchorRect = () => {
|
|
17004
|
-
var _anchorRef$current, _boundingRect$left, _boundingRect$right, _boundingRect$top, _boundingRect$bottom;
|
|
18078
|
+
var _anchorRef$current, _boundingRect$left, _boundingRect$right, _anchorRef$current$ow, _anchorRef$current2, _boundingRect$top, _boundingRect$bottom;
|
|
17005
18079
|
const boundingRect = (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.getBoundingClientRect();
|
|
17006
18080
|
const left = ((_boundingRect$left = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.left) !== null && _boundingRect$left !== void 0 ? _boundingRect$left : 0) - 4;
|
|
17007
|
-
|
|
18081
|
+
const right = (_boundingRect$right = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.right) !== null && _boundingRect$right !== void 0 ? _boundingRect$right : 0;
|
|
18082
|
+
setMenuDirection(getParagraphMenuPopupDirection(left, 212, 8, {
|
|
18083
|
+
anchorRight: right,
|
|
18084
|
+
direction,
|
|
18085
|
+
viewportWidth: (_anchorRef$current$ow = (_anchorRef$current2 = anchorRef.current) === null || _anchorRef$current2 === void 0 || (_anchorRef$current2 = _anchorRef$current2.ownerDocument.defaultView) === null || _anchorRef$current2 === void 0 ? void 0 : _anchorRef$current2.innerWidth) !== null && _anchorRef$current$ow !== void 0 ? _anchorRef$current$ow : window.innerWidth
|
|
18086
|
+
}));
|
|
17008
18087
|
const nextAnchorRect = {
|
|
17009
18088
|
left,
|
|
17010
|
-
right
|
|
18089
|
+
right,
|
|
17011
18090
|
top: (_boundingRect$top = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.top) !== null && _boundingRect$top !== void 0 ? _boundingRect$top : 0,
|
|
17012
18091
|
bottom: (_boundingRect$bottom = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.bottom) !== null && _boundingRect$bottom !== void 0 ? _boundingRect$bottom : 0
|
|
17013
18092
|
};
|
|
@@ -17089,7 +18168,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
17089
18168
|
if (!latestTarget || latestTarget.kind !== "blockRange" || !latestTarget.blockRange || !(doc === null || doc === void 0 ? void 0 : doc.getBody())) return null;
|
|
17090
18169
|
const previousBody = doc.getBody();
|
|
17091
18170
|
const { body, range } = unwrapBlockRangeBody(previousBody, latestTarget.blockRange);
|
|
17092
|
-
const actions =
|
|
18171
|
+
const actions = buildUnwrapBlockRangeActions(previousBody, body, latestTarget.blockRange);
|
|
17093
18172
|
const segmentId = (_activeParagraphBound = activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId) !== null && _activeParagraphBound !== void 0 ? _activeParagraphBound : "";
|
|
17094
18173
|
if (!await commandService.executeCommand(RichTextEditingMutation.id, {
|
|
17095
18174
|
unitId: popup.unitId,
|
|
@@ -17134,14 +18213,12 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
17134
18213
|
}
|
|
17135
18214
|
if (commandId === "doc.menu.paragraph-t.insert-below.command") {
|
|
17136
18215
|
if (!(latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.moveRange)) return;
|
|
17137
|
-
|
|
18216
|
+
docContentInsertService.setInsertRange({
|
|
18217
|
+
unitId: popup.unitId,
|
|
17138
18218
|
startOffset: latestTarget.moveRange.endOffset,
|
|
17139
18219
|
endOffset: latestTarget.moveRange.endOffset,
|
|
17140
|
-
collapsed: true,
|
|
17141
18220
|
segmentId: activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId
|
|
17142
|
-
};
|
|
17143
|
-
replaceSelection(insertRange);
|
|
17144
|
-
await commandService.executeCommand(BreakLineCommand.id, { textRange: insertRange });
|
|
18221
|
+
});
|
|
17145
18222
|
const wrappedCommandId = typeof (commandParams === null || commandParams === void 0 ? void 0 : commandParams.commandId) === "string" ? commandParams.commandId : void 0;
|
|
17146
18223
|
if (wrappedCommandId) await commandService.executeCommand(wrappedCommandId);
|
|
17147
18224
|
finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
|
|
@@ -17446,6 +18523,222 @@ function DragHandleDotsIcon() {
|
|
|
17446
18523
|
});
|
|
17447
18524
|
}
|
|
17448
18525
|
|
|
18526
|
+
//#endregion
|
|
18527
|
+
//#region src/views/section-setting/use-section-setting.ts
|
|
18528
|
+
const DEFAULT_SECTION_COLUMN_GAP = 18;
|
|
18529
|
+
function getCommonValue(values) {
|
|
18530
|
+
const first = values[0];
|
|
18531
|
+
return values.every((value) => value === first) ? first : void 0;
|
|
18532
|
+
}
|
|
18533
|
+
function getSectionColumnCount(section) {
|
|
18534
|
+
var _section$columnProper;
|
|
18535
|
+
return ((_section$columnProper = section.columnProperties) === null || _section$columnProper === void 0 ? void 0 : _section$columnProper.length) || 1;
|
|
18536
|
+
}
|
|
18537
|
+
function getSectionColumnGap(section) {
|
|
18538
|
+
var _section$columnProper2, _section$columnProper3;
|
|
18539
|
+
return (_section$columnProper2 = (_section$columnProper3 = section.columnProperties) === null || _section$columnProper3 === void 0 || (_section$columnProper3 = _section$columnProper3[0]) === null || _section$columnProper3 === void 0 ? void 0 : _section$columnProper3.paddingEnd) !== null && _section$columnProper2 !== void 0 ? _section$columnProper2 : DEFAULT_SECTION_COLUMN_GAP;
|
|
18540
|
+
}
|
|
18541
|
+
function getSectionSettingValues(sections) {
|
|
18542
|
+
return {
|
|
18543
|
+
columnCount: getCommonValue(sections.map(getSectionColumnCount)),
|
|
18544
|
+
columnGap: getCommonValue(sections.map(getSectionColumnGap)),
|
|
18545
|
+
separatorType: getCommonValue(sections.map((section) => {
|
|
18546
|
+
var _section$columnSepara;
|
|
18547
|
+
return (_section$columnSepara = section.columnSeparatorType) !== null && _section$columnSepara !== void 0 ? _section$columnSepara : ColumnSeparatorType.NONE;
|
|
18548
|
+
})),
|
|
18549
|
+
sectionType: getCommonValue(sections.map((section) => {
|
|
18550
|
+
var _section$sectionType;
|
|
18551
|
+
return (_section$sectionType = section.sectionType) !== null && _section$sectionType !== void 0 ? _section$sectionType : SectionType.SECTION_TYPE_UNSPECIFIED;
|
|
18552
|
+
}))
|
|
18553
|
+
};
|
|
18554
|
+
}
|
|
18555
|
+
function createSectionColumnUpdates(sections, documentStyle, change) {
|
|
18556
|
+
return sections.map((section) => {
|
|
18557
|
+
const columnCount = "columnCount" in change ? change.columnCount : getSectionColumnCount(section);
|
|
18558
|
+
const columnGap = "columnGap" in change ? change.columnGap : getSectionColumnGap(section);
|
|
18559
|
+
return {
|
|
18560
|
+
sectionId: section.sectionId,
|
|
18561
|
+
config: { columnProperties: createSectionColumnProperties(documentStyle, section, columnCount, columnGap) }
|
|
18562
|
+
};
|
|
18563
|
+
});
|
|
18564
|
+
}
|
|
18565
|
+
function getSelectedSections(documentDataModel, ranges) {
|
|
18566
|
+
const body = documentDataModel.getBody();
|
|
18567
|
+
if (!body || ranges.length === 0 || ranges.some((range) => Boolean(range.segmentId))) return [];
|
|
18568
|
+
const sections = getTopLevelSectionBreaks(body);
|
|
18569
|
+
return sections.filter((section, index) => {
|
|
18570
|
+
const sectionStart = index === 0 ? 0 : sections[index - 1].startIndex + 1;
|
|
18571
|
+
return ranges.some((range) => {
|
|
18572
|
+
const rangeStart = Math.min(range.startOffset, range.endOffset);
|
|
18573
|
+
const rangeEnd = Math.max(range.startOffset, range.endOffset);
|
|
18574
|
+
return rangeStart <= section.startIndex && rangeEnd >= sectionStart;
|
|
18575
|
+
});
|
|
18576
|
+
});
|
|
18577
|
+
}
|
|
18578
|
+
function useSectionSetting() {
|
|
18579
|
+
const commandService = useDependency(ICommandService);
|
|
18580
|
+
const instanceService = useDependency(IUniverInstanceService);
|
|
18581
|
+
const selectionManager = useDependency(DocSelectionManagerService);
|
|
18582
|
+
const documentDataModel = useObservable(useMemo(() => instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), [instanceService]));
|
|
18583
|
+
useObservable(selectionManager.textSelection$);
|
|
18584
|
+
useObservable(documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.change$);
|
|
18585
|
+
const ranges = selectionManager.getDocRanges();
|
|
18586
|
+
const sections = (documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getDocumentStyle().documentFlavor) === DocumentFlavor.TRADITIONAL ? getSelectedSections(documentDataModel, ranges) : [];
|
|
18587
|
+
const values = getSectionSettingValues(sections);
|
|
18588
|
+
const update = (updates) => {
|
|
18589
|
+
if (!documentDataModel || updates.length === 0) return Promise.resolve(false);
|
|
18590
|
+
return commandService.executeCommand(UpdateDocumentSectionCommand.id, {
|
|
18591
|
+
unitId: documentDataModel.getUnitId(),
|
|
18592
|
+
updates
|
|
18593
|
+
});
|
|
18594
|
+
};
|
|
18595
|
+
const updateAll = (config) => update(sections.map((section) => ({
|
|
18596
|
+
sectionId: section.sectionId,
|
|
18597
|
+
config
|
|
18598
|
+
})));
|
|
18599
|
+
return {
|
|
18600
|
+
valid: Boolean(documentDataModel && sections.length > 0),
|
|
18601
|
+
selectedCount: sections.length,
|
|
18602
|
+
...values,
|
|
18603
|
+
setColumnCount(value) {
|
|
18604
|
+
const next = Math.max(1, Math.round(value));
|
|
18605
|
+
return update(documentDataModel ? createSectionColumnUpdates(sections, documentDataModel.getDocumentStyle(), { columnCount: next }) : []);
|
|
18606
|
+
},
|
|
18607
|
+
setColumnGap(value) {
|
|
18608
|
+
const next = Math.max(0, value);
|
|
18609
|
+
return update(documentDataModel ? createSectionColumnUpdates(sections, documentDataModel.getDocumentStyle(), { columnGap: next }) : []);
|
|
18610
|
+
},
|
|
18611
|
+
setSeparatorType(value) {
|
|
18612
|
+
return updateAll({ columnSeparatorType: value });
|
|
18613
|
+
},
|
|
18614
|
+
setSectionType(value) {
|
|
18615
|
+
return updateAll({ sectionType: value });
|
|
18616
|
+
}
|
|
18617
|
+
};
|
|
18618
|
+
}
|
|
18619
|
+
|
|
18620
|
+
//#endregion
|
|
18621
|
+
//#region src/views/section-setting/Setting.tsx
|
|
18622
|
+
function SettingRow(props) {
|
|
18623
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
18624
|
+
className: "univer-grid univer-min-h-8 univer-items-center univer-gap-3",
|
|
18625
|
+
style: { gridTemplateColumns: "minmax(0, 1fr) minmax(140px, 160px)" },
|
|
18626
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
18627
|
+
className: "univer-min-w-0 univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-text-gray-100",
|
|
18628
|
+
children: props.label
|
|
18629
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
18630
|
+
className: "univer-w-full univer-min-w-0",
|
|
18631
|
+
children: props.children
|
|
18632
|
+
})]
|
|
18633
|
+
});
|
|
18634
|
+
}
|
|
18635
|
+
function SectionSetting() {
|
|
18636
|
+
const localeService = useDependency(LocaleService);
|
|
18637
|
+
const controller = useDependency(DocSectionSettingController);
|
|
18638
|
+
const setting = useSectionSetting();
|
|
18639
|
+
useEffect(() => {
|
|
18640
|
+
if (!setting.valid) controller.closePanel();
|
|
18641
|
+
}, [controller, setting.valid]);
|
|
18642
|
+
if (!setting.valid) return null;
|
|
18643
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
18644
|
+
className: "univer-box-border univer-w-full",
|
|
18645
|
+
children: [setting.selectedCount > 1 && /* @__PURE__ */ jsx("div", {
|
|
18646
|
+
className: "univer-mb-4 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-300",
|
|
18647
|
+
children: localeService.t("docs-ui.doc.sectionSetting.selectedSections", String(setting.selectedCount))
|
|
18648
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
18649
|
+
className: "univer-grid univer-gap-3",
|
|
18650
|
+
children: [
|
|
18651
|
+
/* @__PURE__ */ jsx(SettingRow, {
|
|
18652
|
+
label: localeService.t("docs-ui.doc.sectionSetting.columnCount"),
|
|
18653
|
+
children: /* @__PURE__ */ jsx(InputNumber, {
|
|
18654
|
+
className: "univer-w-full",
|
|
18655
|
+
min: 1,
|
|
18656
|
+
max: 12,
|
|
18657
|
+
step: 1,
|
|
18658
|
+
precision: 0,
|
|
18659
|
+
value: setting.columnCount,
|
|
18660
|
+
onChange: (value) => value != null && setting.setColumnCount(value)
|
|
18661
|
+
})
|
|
18662
|
+
}),
|
|
18663
|
+
/* @__PURE__ */ jsx(SettingRow, {
|
|
18664
|
+
label: `${localeService.t("docs-ui.doc.sectionSetting.columnGap")}(px)`,
|
|
18665
|
+
children: /* @__PURE__ */ jsx(InputNumber, {
|
|
18666
|
+
className: "univer-w-full",
|
|
18667
|
+
min: 0,
|
|
18668
|
+
max: 1e3,
|
|
18669
|
+
step: 1,
|
|
18670
|
+
precision: 1,
|
|
18671
|
+
value: setting.columnGap,
|
|
18672
|
+
onChange: (value) => value != null && setting.setColumnGap(value)
|
|
18673
|
+
})
|
|
18674
|
+
}),
|
|
18675
|
+
/* @__PURE__ */ jsx(SettingRow, {
|
|
18676
|
+
label: localeService.t("docs-ui.doc.sectionSetting.columnSeparator"),
|
|
18677
|
+
children: /* @__PURE__ */ jsx(Select, {
|
|
18678
|
+
className: "univer-w-full",
|
|
18679
|
+
value: setting.separatorType == null ? "" : String(setting.separatorType),
|
|
18680
|
+
options: [{
|
|
18681
|
+
label: localeService.t("docs-ui.doc.sectionSetting.none"),
|
|
18682
|
+
value: String(ColumnSeparatorType.NONE)
|
|
18683
|
+
}, {
|
|
18684
|
+
label: localeService.t("docs-ui.doc.sectionSetting.betweenColumns"),
|
|
18685
|
+
value: String(ColumnSeparatorType.BETWEEN_EACH_COLUMN)
|
|
18686
|
+
}],
|
|
18687
|
+
onChange: (value) => setting.setSeparatorType(Number(value))
|
|
18688
|
+
})
|
|
18689
|
+
}),
|
|
18690
|
+
/* @__PURE__ */ jsx(SettingRow, {
|
|
18691
|
+
label: localeService.t("docs-ui.doc.sectionSetting.sectionStart"),
|
|
18692
|
+
children: /* @__PURE__ */ jsx(Select, {
|
|
18693
|
+
className: "univer-w-full",
|
|
18694
|
+
value: setting.sectionType == null ? "" : String(setting.sectionType),
|
|
18695
|
+
options: [
|
|
18696
|
+
{
|
|
18697
|
+
label: localeService.t("docs-ui.doc.sectionSetting.unspecified"),
|
|
18698
|
+
value: String(SectionType.SECTION_TYPE_UNSPECIFIED)
|
|
18699
|
+
},
|
|
18700
|
+
{
|
|
18701
|
+
label: localeService.t("docs-ui.doc.sectionSetting.continuous"),
|
|
18702
|
+
value: String(SectionType.CONTINUOUS)
|
|
18703
|
+
},
|
|
18704
|
+
{
|
|
18705
|
+
label: localeService.t("docs-ui.doc.sectionSetting.nextPage"),
|
|
18706
|
+
value: String(SectionType.NEXT_PAGE)
|
|
18707
|
+
},
|
|
18708
|
+
{
|
|
18709
|
+
label: localeService.t("docs-ui.doc.sectionSetting.evenPage"),
|
|
18710
|
+
value: String(SectionType.EVEN_PAGE)
|
|
18711
|
+
},
|
|
18712
|
+
{
|
|
18713
|
+
label: localeService.t("docs-ui.doc.sectionSetting.oddPage"),
|
|
18714
|
+
value: String(SectionType.ODD_PAGE)
|
|
18715
|
+
}
|
|
18716
|
+
],
|
|
18717
|
+
onChange: (value) => setting.setSectionType(Number(value))
|
|
18718
|
+
})
|
|
18719
|
+
})
|
|
18720
|
+
]
|
|
18721
|
+
})]
|
|
18722
|
+
});
|
|
18723
|
+
}
|
|
18724
|
+
|
|
18725
|
+
//#endregion
|
|
18726
|
+
//#region src/views/section-setting/index.tsx
|
|
18727
|
+
function SectionSettingIndex() {
|
|
18728
|
+
const commandService = useDependency(ICommandService);
|
|
18729
|
+
useObservable(useDependency(LocaleService).currentLocale$);
|
|
18730
|
+
const [key, setKey] = useState(() => generateRandomId(4));
|
|
18731
|
+
useEffect(() => {
|
|
18732
|
+
const disposable = commandService.onCommandExecuted((info) => {
|
|
18733
|
+
if (info.id === SetTextSelectionsOperation.id) {
|
|
18734
|
+
if (info.params.ranges.length > 0) setKey(generateRandomId(4));
|
|
18735
|
+
} else if (info.id === RichTextEditingMutation.id) setKey(generateRandomId(4));
|
|
18736
|
+
});
|
|
18737
|
+
return () => disposable.dispose();
|
|
18738
|
+
}, [commandService]);
|
|
18739
|
+
return /* @__PURE__ */ jsx(SectionSetting, {}, key);
|
|
18740
|
+
}
|
|
18741
|
+
|
|
17449
18742
|
//#endregion
|
|
17450
18743
|
//#region src/views/table/create/TableCreate.tsx
|
|
17451
18744
|
const DocCreateTableConfirm = ({ handleRowColChange, tableCreateParams }) => {
|
|
@@ -17549,6 +18842,8 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
17549
18842
|
KeyboardIcon,
|
|
17550
18843
|
LeftInsertColumnDoubleIcon,
|
|
17551
18844
|
LeftJustifyingIcon,
|
|
18845
|
+
LineIndentDecreaseIcon,
|
|
18846
|
+
LineIndentIncreaseIcon,
|
|
17552
18847
|
MenuIcon,
|
|
17553
18848
|
TextTypeIcon,
|
|
17554
18849
|
NoColorDoubleIcon,
|
|
@@ -17600,6 +18895,7 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
17600
18895
|
_registerComponents() {
|
|
17601
18896
|
if (!this._componentManager.get("COMPONENT_DOC_HEADER_FOOTER_PANEL")) this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, DocHeaderFooterPanel));
|
|
17602
18897
|
this.disposeWithMe(this._componentManager.register(paragraphSettingIndexKey, ParagraphSettingIndex));
|
|
18898
|
+
this.disposeWithMe(this._componentManager.register(DOC_SECTION_SETTING_COMPONENT, SectionSettingIndex));
|
|
17603
18899
|
[
|
|
17604
18900
|
[BULLET_LIST_TYPE_COMPONENT, BulletListTypePicker],
|
|
17605
18901
|
[ORDER_LIST_TYPE_COMPONENT, OrderListTypePicker],
|
|
@@ -17837,48 +19133,33 @@ var TextBubbleShape = class TextBubbleShape extends Shape {
|
|
|
17837
19133
|
//#region src/controllers/doc-header-footer.controller.ts
|
|
17838
19134
|
const HEADER_FOOTER_STROKE_COLOR = "rgba(58, 96, 247, 1)";
|
|
17839
19135
|
const HEADER_FOOTER_FILL_COLOR = "rgba(58, 96, 247, 0.08)";
|
|
17840
|
-
function checkCreateHeaderFooterType(viewModel, editArea, segmentPage) {
|
|
17841
|
-
const {
|
|
17842
|
-
const { defaultHeaderId, defaultFooterId, evenPageHeaderId, evenPageFooterId, firstPageHeaderId, firstPageFooterId, evenAndOddHeaders, useFirstPageHeaderFooter } =
|
|
17843
|
-
|
|
17844
|
-
|
|
17845
|
-
|
|
17846
|
-
|
|
17847
|
-
|
|
17848
|
-
|
|
17849
|
-
|
|
17850
|
-
|
|
17851
|
-
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
|
|
17857
|
-
|
|
17858
|
-
|
|
17859
|
-
|
|
17860
|
-
|
|
17861
|
-
|
|
17862
|
-
|
|
17863
|
-
|
|
17864
|
-
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
headerFooterId: null
|
|
17868
|
-
};
|
|
17869
|
-
if (evenAndOddHeaders === BooleanNumber.TRUE && segmentPage % 2 === 0 && !evenPageFooterId) return {
|
|
17870
|
-
createType: HeaderFooterType.EVEN_PAGE_FOOTER,
|
|
17871
|
-
headerFooterId: null
|
|
17872
|
-
};
|
|
17873
|
-
return defaultFooterId ? {
|
|
17874
|
-
createType: null,
|
|
17875
|
-
headerFooterId: defaultFooterId
|
|
17876
|
-
} : {
|
|
17877
|
-
createType: HeaderFooterType.DEFAULT_FOOTER,
|
|
17878
|
-
headerFooterId: null
|
|
17879
|
-
};
|
|
17880
|
-
default: throw new Error(`Invalid editArea: ${editArea}`);
|
|
17881
|
-
}
|
|
19136
|
+
function checkCreateHeaderFooterType(viewModel, editArea, segmentPage, page) {
|
|
19137
|
+
const { sectionId, config } = getDocPageSectionContext(viewModel.getDataModel().getSnapshot(), page);
|
|
19138
|
+
const { defaultHeaderId, defaultFooterId, evenPageHeaderId, evenPageFooterId, firstPageHeaderId, firstPageFooterId, evenAndOddHeaders, useFirstPageHeaderFooter } = config;
|
|
19139
|
+
const isFirstPage = page ? page.pageNumber === page.pageNumberStart : segmentPage === 0;
|
|
19140
|
+
const isEvenPage = page ? page.pageNumber % 2 === 0 : segmentPage % 2 === 1;
|
|
19141
|
+
if (editArea === DocumentEditArea.BODY) return {
|
|
19142
|
+
createType: null,
|
|
19143
|
+
headerFooterId: null,
|
|
19144
|
+
sectionId
|
|
19145
|
+
};
|
|
19146
|
+
const isHeader = editArea === DocumentEditArea.HEADER;
|
|
19147
|
+
if (!isHeader && editArea !== DocumentEditArea.FOOTER) throw new Error(`Invalid editArea: ${editArea}`);
|
|
19148
|
+
const variants = isHeader ? {
|
|
19149
|
+
first: [firstPageHeaderId, HeaderFooterType.FIRST_PAGE_HEADER],
|
|
19150
|
+
even: [evenPageHeaderId, HeaderFooterType.EVEN_PAGE_HEADER],
|
|
19151
|
+
default: [defaultHeaderId, HeaderFooterType.DEFAULT_HEADER]
|
|
19152
|
+
} : {
|
|
19153
|
+
first: [firstPageFooterId, HeaderFooterType.FIRST_PAGE_FOOTER],
|
|
19154
|
+
even: [evenPageFooterId, HeaderFooterType.EVEN_PAGE_FOOTER],
|
|
19155
|
+
default: [defaultFooterId, HeaderFooterType.DEFAULT_FOOTER]
|
|
19156
|
+
};
|
|
19157
|
+
const [headerFooterId, createType] = useFirstPageHeaderFooter === BooleanNumber.TRUE && isFirstPage ? variants.first : evenAndOddHeaders === BooleanNumber.TRUE && isEvenPage ? variants.even : variants.default;
|
|
19158
|
+
return {
|
|
19159
|
+
createType: headerFooterId ? null : createType,
|
|
19160
|
+
headerFooterId: headerFooterId !== null && headerFooterId !== void 0 ? headerFooterId : null,
|
|
19161
|
+
sectionId
|
|
19162
|
+
};
|
|
17882
19163
|
}
|
|
17883
19164
|
let DocHeaderFooterController = class DocHeaderFooterController extends Disposable {
|
|
17884
19165
|
constructor(_context, _commandService, _editorService, _instanceSrv, _renderManagerService, _docSkeletonManagerService, _docSelectionRenderService, _localeService) {
|
|
@@ -17924,6 +19205,7 @@ let DocHeaderFooterController = class DocHeaderFooterController extends Disposab
|
|
|
17924
19205
|
_initialMain(unitId) {
|
|
17925
19206
|
const { document } = neoGetDocObject(this._context);
|
|
17926
19207
|
this.disposeWithMe(document.onDblclick$.subscribeEvent(async (evt) => {
|
|
19208
|
+
var _skeleton$getSkeleton;
|
|
17927
19209
|
if (this._isEditorReadOnly(unitId)) return;
|
|
17928
19210
|
if (!this._isTraditionalMode()) return;
|
|
17929
19211
|
const { offsetX, offsetY } = evt;
|
|
@@ -17934,9 +19216,9 @@ let DocHeaderFooterController = class DocHeaderFooterController extends Disposab
|
|
|
17934
19216
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
17935
19217
|
const preEditArea = viewModel.getEditArea();
|
|
17936
19218
|
const { editArea, pageNumber } = skeleton.findEditAreaByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
17937
|
-
if (preEditArea === editArea) return;
|
|
19219
|
+
if (preEditArea === editArea && (editArea === DocumentEditArea.BODY || this._docSelectionRenderService.getSegmentPage() === pageNumber)) return;
|
|
17938
19220
|
viewModel.setEditArea(editArea);
|
|
17939
|
-
const { createType, headerFooterId } = checkCreateHeaderFooterType(viewModel, editArea, pageNumber);
|
|
19221
|
+
const { createType, headerFooterId, sectionId } = checkCreateHeaderFooterType(viewModel, editArea, pageNumber, (_skeleton$getSkeleton = skeleton.getSkeletonData()) === null || _skeleton$getSkeleton === void 0 ? void 0 : _skeleton$getSkeleton.pages[pageNumber]);
|
|
17940
19222
|
if (editArea === DocumentEditArea.BODY) {
|
|
17941
19223
|
this._docSelectionRenderService.setSegment("");
|
|
17942
19224
|
this._docSelectionRenderService.setSegmentPage(-1);
|
|
@@ -17948,7 +19230,8 @@ let DocHeaderFooterController = class DocHeaderFooterController extends Disposab
|
|
|
17948
19230
|
await this._commandService.executeCommand(CoreHeaderFooterCommand.id, {
|
|
17949
19231
|
unitId,
|
|
17950
19232
|
createType,
|
|
17951
|
-
segmentId
|
|
19233
|
+
segmentId,
|
|
19234
|
+
sectionId
|
|
17952
19235
|
});
|
|
17953
19236
|
} else if (headerFooterId != null) {
|
|
17954
19237
|
this._docSelectionRenderService.setSegment(headerFooterId);
|
|
@@ -18560,13 +19843,10 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
|
|
|
18560
19843
|
line: newLine,
|
|
18561
19844
|
offsetLeft
|
|
18562
19845
|
};
|
|
18563
|
-
if (this._isColumnGroupContentPage(page))
|
|
18564
|
-
const exitTarget = this._getColumnGroupExitLineTarget(page, direction, offsetLeft);
|
|
18565
|
-
if (exitTarget != null) return exitTarget;
|
|
18566
|
-
}
|
|
19846
|
+
if (this._isColumnGroupContentPage(page)) return this._getColumnGroupExitLineTarget(page, direction, offsetLeft);
|
|
18567
19847
|
if (this._isTableCellContentPage(page)) return this._getAdjacentTableCellLineTarget(page, direction, offsetLeft);
|
|
18568
19848
|
const skeleton = page.parent;
|
|
18569
|
-
if (skeleton == null) return;
|
|
19849
|
+
if ((skeleton === null || skeleton === void 0 ? void 0 : skeleton.pages) == null) return;
|
|
18570
19850
|
const currentPageIndex = skeleton.pages.indexOf(page);
|
|
18571
19851
|
if (currentPageIndex === -1) return;
|
|
18572
19852
|
if (direction === true) {
|
|
@@ -19193,13 +20473,14 @@ DocIMEInputController = __decorate([
|
|
|
19193
20473
|
//#endregion
|
|
19194
20474
|
//#region src/controllers/render-controllers/doc-input.controller.ts
|
|
19195
20475
|
let DocInputController = class DocInputController extends Disposable {
|
|
19196
|
-
constructor(_context, _docSelectionRenderService, _docSkeletonManagerService, _commandService, _docMenuStyleService) {
|
|
20476
|
+
constructor(_context, _docSelectionRenderService, _docSkeletonManagerService, _commandService, _docMenuStyleService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
19197
20477
|
super();
|
|
19198
20478
|
this._context = _context;
|
|
19199
20479
|
this._docSelectionRenderService = _docSelectionRenderService;
|
|
19200
20480
|
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
19201
20481
|
this._commandService = _commandService;
|
|
19202
20482
|
this._docMenuStyleService = _docMenuStyleService;
|
|
20483
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
19203
20484
|
_defineProperty(this, "_onInputSubscription", void 0);
|
|
19204
20485
|
this._init();
|
|
19205
20486
|
}
|
|
@@ -19219,6 +20500,7 @@ let DocInputController = class DocInputController extends Disposable {
|
|
|
19219
20500
|
const { event, content = "", activeRange } = config;
|
|
19220
20501
|
const e = event;
|
|
19221
20502
|
if (e.defaultPrevented) return;
|
|
20503
|
+
if (!SHEET_EDITOR_UNITS.includes(unitId) && this._isEmbedChildInputActive(unitId, e)) return;
|
|
19222
20504
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
19223
20505
|
if (e.data == null || skeleton == null || activeRange == null) return;
|
|
19224
20506
|
const { segmentId } = activeRange;
|
|
@@ -19255,12 +20537,21 @@ let DocInputController = class DocInputController extends Disposable {
|
|
|
19255
20537
|
if (content === " ") await this._commandService.executeCommand(AfterSpaceCommand.id);
|
|
19256
20538
|
});
|
|
19257
20539
|
}
|
|
20540
|
+
_isEmbedChildInputActive(unitId, event) {
|
|
20541
|
+
var _this$_embedRuntimeFo, _this$_embedRuntimeFo2, _this$_embedRuntimeFo3;
|
|
20542
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.isChildUnitRuntimeEvent(unitId, event.target, event)) return false;
|
|
20543
|
+
if ((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(unitId)) return false;
|
|
20544
|
+
if ((_this$_embedRuntimeFo3 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo3 === void 0 ? void 0 : _this$_embedRuntimeFo3.shouldSuppressHostInteraction(unitId, event.target, event)) return true;
|
|
20545
|
+
return false;
|
|
20546
|
+
}
|
|
19258
20547
|
};
|
|
19259
20548
|
DocInputController = __decorate([
|
|
19260
20549
|
__decorateParam(1, Inject(DocSelectionRenderService)),
|
|
19261
20550
|
__decorateParam(2, Inject(DocSkeletonManagerService)),
|
|
19262
20551
|
__decorateParam(3, ICommandService),
|
|
19263
|
-
__decorateParam(4, Inject(DocMenuStyleService))
|
|
20552
|
+
__decorateParam(4, Inject(DocMenuStyleService)),
|
|
20553
|
+
__decorateParam(5, Optional(IDocEmbedInteractionBoundaryService)),
|
|
20554
|
+
__decorateParam(6, Optional(IDocEmbedRuntimeFocusCoordinator))
|
|
19264
20555
|
], DocInputController);
|
|
19265
20556
|
|
|
19266
20557
|
//#endregion
|
|
@@ -19288,7 +20579,7 @@ DocResizeRenderController = __decorate([__decorateParam(1, Inject(DocPageLayoutS
|
|
|
19288
20579
|
//#endregion
|
|
19289
20580
|
//#region src/controllers/render-controllers/doc-selection-render.controller.ts
|
|
19290
20581
|
let DocSelectionRenderController = class DocSelectionRenderController extends Disposable {
|
|
19291
|
-
constructor(_context, _commandService, _editorService, _instanceSrv, _docSelectionRenderService, _docSkeletonManagerService, _docSelectionManagerService) {
|
|
20582
|
+
constructor(_context, _commandService, _editorService, _instanceSrv, _docSelectionRenderService, _docSkeletonManagerService, _docSelectionManagerService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
19292
20583
|
super();
|
|
19293
20584
|
this._context = _context;
|
|
19294
20585
|
this._commandService = _commandService;
|
|
@@ -19297,6 +20588,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends Di
|
|
|
19297
20588
|
this._docSelectionRenderService = _docSelectionRenderService;
|
|
19298
20589
|
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
19299
20590
|
this._docSelectionManagerService = _docSelectionManagerService;
|
|
20591
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
19300
20592
|
_defineProperty(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
|
|
19301
20593
|
this._initialize();
|
|
19302
20594
|
}
|
|
@@ -19328,6 +20620,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends Di
|
|
|
19328
20620
|
_syncSelection() {
|
|
19329
20621
|
this.disposeWithMe(this._docSelectionRenderService.textSelectionInner$.subscribe((params) => {
|
|
19330
20622
|
if (params == null) return;
|
|
20623
|
+
if (!isInternalEditorID(this._context.unitId) && this._isEmbedChildInteractionActive(this._context.unitId)) return;
|
|
19331
20624
|
this._docSelectionManagerService.__replaceTextRangesWithNoRefresh(params, {
|
|
19332
20625
|
unitId: this._context.unitId,
|
|
19333
20626
|
subUnitId: this._context.unitId
|
|
@@ -19346,8 +20639,10 @@ let DocSelectionRenderController = class DocSelectionRenderController extends Di
|
|
|
19346
20639
|
}));
|
|
19347
20640
|
this.disposeWithMe(document.onPointerDown$.subscribeEvent((evt, state) => {
|
|
19348
20641
|
if (this._isEditorReadOnly(unitId)) return;
|
|
20642
|
+
if (this._isEmbedInteractionEvent(evt, unitId)) return;
|
|
19349
20643
|
const docDataModel = this._instanceSrv.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
19350
20644
|
if ((docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId()) !== unitId) this._instanceSrv.setCurrentUnitForType(unitId);
|
|
20645
|
+
this._instanceSrv.focusUnit(unitId);
|
|
19351
20646
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
19352
20647
|
const { offsetX, offsetY } = evt;
|
|
19353
20648
|
const coord = this._getTransformCoordForDocumentOffset(offsetX, offsetY);
|
|
@@ -19380,10 +20675,12 @@ let DocSelectionRenderController = class DocSelectionRenderController extends Di
|
|
|
19380
20675
|
}));
|
|
19381
20676
|
this.disposeWithMe(document.onDblclick$.subscribeEvent((evt) => {
|
|
19382
20677
|
if (this._isEditorReadOnly(unitId)) return;
|
|
20678
|
+
if (this._isEmbedInteractionEvent(evt, unitId)) return;
|
|
19383
20679
|
this._docSelectionRenderService.__handleDblClick(evt);
|
|
19384
20680
|
}));
|
|
19385
20681
|
this.disposeWithMe(document.onTripleClick$.subscribeEvent((evt) => {
|
|
19386
20682
|
if (this._isEditorReadOnly(unitId)) return;
|
|
20683
|
+
if (this._isEmbedInteractionEvent(evt, unitId)) return;
|
|
19387
20684
|
this._docSelectionRenderService.__handleTripleClick(evt);
|
|
19388
20685
|
}));
|
|
19389
20686
|
}
|
|
@@ -19403,6 +20700,19 @@ let DocSelectionRenderController = class DocSelectionRenderController extends Di
|
|
|
19403
20700
|
_setEditorFocus(unitId) {
|
|
19404
20701
|
this._editorService.focus(unitId);
|
|
19405
20702
|
}
|
|
20703
|
+
_isEmbedInteractionEvent(evt, unitId) {
|
|
20704
|
+
var _this$_embedRuntimeFo, _this$_embedRuntimeFo2, _this$_embedRuntimeFo3;
|
|
20705
|
+
if (isInternalEditorID(unitId)) return false;
|
|
20706
|
+
const target = evt.target;
|
|
20707
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.isChildUnitRuntimeEvent(unitId, target, evt)) return false;
|
|
20708
|
+
if ((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(unitId)) return false;
|
|
20709
|
+
if ((_this$_embedRuntimeFo3 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo3 === void 0 ? void 0 : _this$_embedRuntimeFo3.shouldSuppressHostInteraction(unitId, target, evt)) return true;
|
|
20710
|
+
return isEmbedInteractionEvent(evt);
|
|
20711
|
+
}
|
|
20712
|
+
_isEmbedChildInteractionActive(unitId) {
|
|
20713
|
+
var _this$_embedRuntimeFo4;
|
|
20714
|
+
return ((_this$_embedRuntimeFo4 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo4 === void 0 ? void 0 : _this$_embedRuntimeFo4.shouldSuppressHostInteraction(unitId)) === true;
|
|
20715
|
+
}
|
|
19406
20716
|
_commandExecutedListener() {
|
|
19407
20717
|
const updateCommandList = [SetDocZoomRatioOperation.id];
|
|
19408
20718
|
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
@@ -19410,6 +20720,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends Di
|
|
|
19410
20720
|
var _this$_docSelectionMa;
|
|
19411
20721
|
const { unitId: documentId } = command.params;
|
|
19412
20722
|
if (documentId !== ((_this$_docSelectionMa = this._docSelectionManagerService.__getCurrentSelection()) === null || _this$_docSelectionMa === void 0 ? void 0 : _this$_docSelectionMa.unitId)) return;
|
|
20723
|
+
if (this._isEmbedChildInteractionActive(documentId)) return;
|
|
19413
20724
|
this._docSelectionManagerService.refreshSelection();
|
|
19414
20725
|
}
|
|
19415
20726
|
}));
|
|
@@ -19419,6 +20730,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends Di
|
|
|
19419
20730
|
if (!skeleton) return;
|
|
19420
20731
|
const { unitId } = this._context;
|
|
19421
20732
|
if (!isInternalEditorID(unitId)) {
|
|
20733
|
+
if (this._isEmbedChildInteractionActive(unitId)) return;
|
|
19422
20734
|
this._docSelectionRenderService.focus();
|
|
19423
20735
|
const offset = findFirstCursorOffset(this._context.unit.getSnapshot());
|
|
19424
20736
|
this._docSelectionManagerService.replaceDocRanges([{
|
|
@@ -19438,8 +20750,39 @@ DocSelectionRenderController = __decorate([
|
|
|
19438
20750
|
__decorateParam(3, IUniverInstanceService),
|
|
19439
20751
|
__decorateParam(4, Inject(DocSelectionRenderService)),
|
|
19440
20752
|
__decorateParam(5, Inject(DocSkeletonManagerService)),
|
|
19441
|
-
__decorateParam(6, Inject(DocSelectionManagerService))
|
|
20753
|
+
__decorateParam(6, Inject(DocSelectionManagerService)),
|
|
20754
|
+
__decorateParam(7, Optional(IDocEmbedInteractionBoundaryService)),
|
|
20755
|
+
__decorateParam(8, Optional(IDocEmbedRuntimeFocusCoordinator))
|
|
19442
20756
|
], DocSelectionRenderController);
|
|
20757
|
+
function isEmbedInteractionEvent(evt) {
|
|
20758
|
+
var _document$elementFrom;
|
|
20759
|
+
const target = evt.target;
|
|
20760
|
+
if (typeof Element !== "undefined" && target instanceof Element && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null) return true;
|
|
20761
|
+
if (typeof document === "undefined") return false;
|
|
20762
|
+
const point = getEventClientPoint(evt, target);
|
|
20763
|
+
const clientX = point === null || point === void 0 ? void 0 : point.clientX;
|
|
20764
|
+
const clientY = point === null || point === void 0 ? void 0 : point.clientY;
|
|
20765
|
+
if (typeof clientX !== "number" || typeof clientY !== "number" || !Number.isFinite(clientX) || !Number.isFinite(clientY)) return false;
|
|
20766
|
+
if (typeof document.elementFromPoint !== "function") return false;
|
|
20767
|
+
return ((_document$elementFrom = document.elementFromPoint(clientX, clientY)) === null || _document$elementFrom === void 0 ? void 0 : _document$elementFrom.closest(`[${DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`)) != null;
|
|
20768
|
+
}
|
|
20769
|
+
function getEventClientPoint(evt, target) {
|
|
20770
|
+
if (Number.isFinite(evt.clientX) && Number.isFinite(evt.clientY)) return {
|
|
20771
|
+
clientX: evt.clientX,
|
|
20772
|
+
clientY: evt.clientY
|
|
20773
|
+
};
|
|
20774
|
+
if (typeof Element !== "undefined" && target instanceof Element && Number.isFinite(evt.offsetX) && Number.isFinite(evt.offsetY)) {
|
|
20775
|
+
const rect = target.getBoundingClientRect();
|
|
20776
|
+
return {
|
|
20777
|
+
clientX: rect.left + evt.offsetX,
|
|
20778
|
+
clientY: rect.top + evt.offsetY
|
|
20779
|
+
};
|
|
20780
|
+
}
|
|
20781
|
+
if (Number.isFinite(evt.x) && Number.isFinite(evt.y)) return {
|
|
20782
|
+
clientX: evt.x,
|
|
20783
|
+
clientY: evt.y
|
|
20784
|
+
};
|
|
20785
|
+
}
|
|
19443
20786
|
|
|
19444
20787
|
//#endregion
|
|
19445
20788
|
//#region src/controllers/render-controllers/zoom.render-controller.ts
|
|
@@ -19447,7 +20790,7 @@ function shouldHandleDocWheelZoom(event, focusingDoc, _documentFlavor) {
|
|
|
19447
20790
|
return focusingDoc && (event.ctrlKey || event.metaKey);
|
|
19448
20791
|
}
|
|
19449
20792
|
let DocZoomRenderController = class DocZoomRenderController extends Disposable {
|
|
19450
|
-
constructor(_context, _contextService, _docSkeletonManagerService, _univerInstanceService, _commandService, _textSelectionManagerService, _editorService, _docPageLayoutService, _renderManagerService, _docViewScaleService) {
|
|
20793
|
+
constructor(_context, _contextService, _docSkeletonManagerService, _univerInstanceService, _commandService, _textSelectionManagerService, _editorService, _docPageLayoutService, _renderManagerService, _docViewScaleService, _embedInteractionBoundaryService) {
|
|
19451
20794
|
super();
|
|
19452
20795
|
this._context = _context;
|
|
19453
20796
|
this._contextService = _contextService;
|
|
@@ -19459,6 +20802,7 @@ let DocZoomRenderController = class DocZoomRenderController extends Disposable {
|
|
|
19459
20802
|
this._docPageLayoutService = _docPageLayoutService;
|
|
19460
20803
|
this._renderManagerService = _renderManagerService;
|
|
19461
20804
|
this._docViewScaleService = _docViewScaleService;
|
|
20805
|
+
this._embedInteractionBoundaryService = _embedInteractionBoundaryService;
|
|
19462
20806
|
_defineProperty(this, "_isSheetEditor", false);
|
|
19463
20807
|
_defineProperty(this, "_initTimer", void 0);
|
|
19464
20808
|
_defineProperty(this, "_updateTimer", void 0);
|
|
@@ -19508,14 +20852,21 @@ let DocZoomRenderController = class DocZoomRenderController extends Disposable {
|
|
|
19508
20852
|
}));
|
|
19509
20853
|
}
|
|
19510
20854
|
updateViewZoom(zoomRatio, needRefreshSelection = true) {
|
|
19511
|
-
var
|
|
20855
|
+
var _this$_embedInteracti;
|
|
19512
20856
|
const docObject = neoGetDocObject(this._context);
|
|
19513
20857
|
const viewScale = this._docViewScaleService.getViewScale(zoomRatio);
|
|
19514
20858
|
docObject.scene.scale(viewScale, viewScale);
|
|
19515
20859
|
if (!this._editorService.isEditor(this._context.unitId)) this._docPageLayoutService.calculatePagePosition();
|
|
19516
|
-
if (needRefreshSelection && !this._editorService.isEditor(this._context.unitId)) this._textSelectionManagerService.refreshSelection();
|
|
19517
|
-
if (isInternalEditorID(this._context.unitId))
|
|
19518
|
-
|
|
20860
|
+
if (needRefreshSelection && !this._editorService.isEditor(this._context.unitId) && !((_this$_embedInteracti = this._embedInteractionBoundaryService) === null || _this$_embedInteracti === void 0 ? void 0 : _this$_embedInteracti.hasRecentInteraction())) this._textSelectionManagerService.refreshSelection();
|
|
20861
|
+
if (!isInternalEditorID(this._context.unitId)) {
|
|
20862
|
+
var _docObject$scene$getT;
|
|
20863
|
+
(_docObject$scene$getT = docObject.scene.getTransformer()) === null || _docObject$scene$getT === void 0 || _docObject$scene$getT.clearSelectedObjects();
|
|
20864
|
+
}
|
|
20865
|
+
const createOptions = this._univerInstanceService.getUnitCreateOptions(this._context.unitId);
|
|
20866
|
+
if ((createOptions === null || createOptions === void 0 ? void 0 : createOptions.embeddedRender) === true || (createOptions === null || createOptions === void 0 ? void 0 : createOptions.skipAutoRender) === true) {
|
|
20867
|
+
this._context.scene.makeDirty();
|
|
20868
|
+
this._context.scene.render();
|
|
20869
|
+
}
|
|
19519
20870
|
}
|
|
19520
20871
|
_initZoomEventListener() {
|
|
19521
20872
|
const scene = this._context.scene;
|
|
@@ -19542,7 +20893,8 @@ DocZoomRenderController = __decorate([
|
|
|
19542
20893
|
__decorateParam(6, IEditorService),
|
|
19543
20894
|
__decorateParam(7, Inject(DocPageLayoutService)),
|
|
19544
20895
|
__decorateParam(8, IRenderManagerService),
|
|
19545
|
-
__decorateParam(9, Inject(DocViewScaleService))
|
|
20896
|
+
__decorateParam(9, Inject(DocViewScaleService)),
|
|
20897
|
+
__decorateParam(10, Optional(IDocEmbedInteractionBoundaryService))
|
|
19546
20898
|
], DocZoomRenderController);
|
|
19547
20899
|
|
|
19548
20900
|
//#endregion
|
|
@@ -19625,25 +20977,34 @@ let DocsRenderService = class DocsRenderService extends RxDisposable {
|
|
|
19625
20977
|
}
|
|
19626
20978
|
_init() {
|
|
19627
20979
|
this._renderManagerService.createRender$.pipe(takeUntil(this.dispose$)).subscribe((unitId) => this._createRenderWithId(unitId));
|
|
19628
|
-
this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_DOC).forEach((documentModel) =>
|
|
19629
|
-
|
|
20980
|
+
this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_DOC).forEach((documentModel) => {
|
|
20981
|
+
var _this$_instanceSrv$ge;
|
|
20982
|
+
return this._createRenderer(documentModel, (_this$_instanceSrv$ge = this._instanceSrv.getUnitCreateOptions(documentModel.getUnitId())) !== null && _this$_instanceSrv$ge !== void 0 ? _this$_instanceSrv$ge : void 0);
|
|
20983
|
+
});
|
|
20984
|
+
this._instanceSrv.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((event) => this._createRenderer(event.unit, event.options));
|
|
19630
20985
|
this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((doc) => this._disposeRenderer(doc));
|
|
19631
20986
|
}
|
|
19632
|
-
_createRenderer(doc) {
|
|
20987
|
+
_createRenderer(doc, createUnitOptions) {
|
|
20988
|
+
if (createUnitOptions === null || createUnitOptions === void 0 ? void 0 : createUnitOptions.skipAutoRender) return;
|
|
19633
20989
|
const unitId = doc.getUnitId();
|
|
19634
|
-
this._renderManagerService.
|
|
19635
|
-
|
|
19636
|
-
|
|
19637
|
-
|
|
19638
|
-
|
|
19639
|
-
|
|
19640
|
-
canvas.getCanvasEle().style.backgroundColor = getDocsCanvasBackgroundColor(documentFlavor, renderer.engine.canvasColorService, void 0, isInternalEditorID(unitId));
|
|
19641
|
-
}
|
|
19642
|
-
});
|
|
19643
|
-
if (!this._renderManagerService.has(unitId)) this._createRenderWithId(unitId);
|
|
20990
|
+
if (!this._renderManagerService.has(unitId)) {
|
|
20991
|
+
this._createRenderWithId(unitId, doc);
|
|
20992
|
+
return;
|
|
20993
|
+
}
|
|
20994
|
+
const renderer = this._renderManagerService.getRenderById(unitId);
|
|
20995
|
+
if (renderer) this._syncRendererCanvas(renderer, doc);
|
|
19644
20996
|
}
|
|
19645
|
-
_createRenderWithId(unitId) {
|
|
19646
|
-
this._renderManagerService.createRender(unitId);
|
|
20997
|
+
_createRenderWithId(unitId, doc) {
|
|
20998
|
+
const renderer = this._renderManagerService.createRender(unitId);
|
|
20999
|
+
if (doc) this._syncRendererCanvas(renderer, doc);
|
|
21000
|
+
}
|
|
21001
|
+
_syncRendererCanvas(renderer, doc) {
|
|
21002
|
+
const unitId = doc.getUnitId();
|
|
21003
|
+
const documentFlavor = doc.getSnapshot().documentStyle.documentFlavor;
|
|
21004
|
+
const canvas = renderer.engine.getCanvas();
|
|
21005
|
+
canvas.setId(DOC_MAIN_CANVAS_ID);
|
|
21006
|
+
canvas.getContext().setId(DOC_MAIN_CANVAS_ID);
|
|
21007
|
+
canvas.getCanvasEle().style.backgroundColor = getDocsCanvasBackgroundColor(documentFlavor, renderer.engine.canvasColorService, void 0, isInternalEditorID(unitId));
|
|
19647
21008
|
}
|
|
19648
21009
|
_disposeRenderer(doc) {
|
|
19649
21010
|
const unitId = doc.getUnitId();
|
|
@@ -19829,6 +21190,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
|
|
|
19829
21190
|
[DocAutoFormatController],
|
|
19830
21191
|
[DocMoveCursorController],
|
|
19831
21192
|
[DocParagraphSettingController],
|
|
21193
|
+
[DocSectionSettingController],
|
|
19832
21194
|
[DocTableController],
|
|
19833
21195
|
[ComponentsController],
|
|
19834
21196
|
[DocUIController]
|
|
@@ -19898,6 +21260,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
|
|
|
19898
21260
|
SetDocZoomRatioCommand,
|
|
19899
21261
|
DocSelectAllCommand,
|
|
19900
21262
|
DocParagraphSettingPanelOperation,
|
|
21263
|
+
DocSectionSettingPanelOperation,
|
|
19901
21264
|
MoveCursorOperation,
|
|
19902
21265
|
MoveSelectionOperation,
|
|
19903
21266
|
ReplaceTextRunsCommand,
|
|
@@ -19985,8 +21348,11 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
|
|
|
19985
21348
|
[DocTableController],
|
|
19986
21349
|
[DocMoveCursorController],
|
|
19987
21350
|
[DocParagraphSettingController],
|
|
21351
|
+
[DocSectionSettingController],
|
|
19988
21352
|
[IEditorService, { useClass: EditorService }],
|
|
19989
21353
|
[IDocClipboardService, { useClass: DocClipboardService }],
|
|
21354
|
+
[DocClipboardPasteAdapterService],
|
|
21355
|
+
[IDocClipboardPasteAdapterService, { useClass: DocClipboardPasteAdapterService }],
|
|
19990
21356
|
[DocHtmlExportService],
|
|
19991
21357
|
[DocCanvasPopManagerService],
|
|
19992
21358
|
[DocsRenderService],
|
|
@@ -20002,6 +21368,8 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
|
|
|
20002
21368
|
const doc = currentService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
20003
21369
|
if (!doc) return;
|
|
20004
21370
|
const id = doc.getUnitId();
|
|
21371
|
+
const createOptions = currentService.getUnitCreateOptions(id);
|
|
21372
|
+
if ((createOptions === null || createOptions === void 0 ? void 0 : createOptions.makeCurrent) === false) return;
|
|
20005
21373
|
if (!editorService.isEditor(id)) currentService.focusUnit(doc.getUnitId());
|
|
20006
21374
|
} catch (err) {
|
|
20007
21375
|
this._logService.warn(err);
|
|
@@ -20278,13 +21646,13 @@ function useKeyboardEvent(isNeed, config, editor) {
|
|
|
20278
21646
|
const useLeftAndRightArrow = (isNeed, selectingMode, editor, onMoveInEditor) => {
|
|
20279
21647
|
const commandService = useDependency(ICommandService);
|
|
20280
21648
|
const shortcutService = useDependency(IShortcutService);
|
|
21649
|
+
const operationId = `doc.rich-text-editor.arrow.${useId()}`;
|
|
20281
21650
|
const selectingModeRef = useRef(selectingMode);
|
|
20282
21651
|
selectingModeRef.current = selectingMode;
|
|
20283
21652
|
const onMoveInEditorRef = useRef(onMoveInEditor);
|
|
20284
21653
|
onMoveInEditorRef.current = onMoveInEditor;
|
|
20285
21654
|
useEffect(() => {
|
|
20286
21655
|
if (!editor || !isNeed) return;
|
|
20287
|
-
const operationId = `doc.rich-text-editor.${editor.getEditorId()}`;
|
|
20288
21656
|
const d = new DisposableCollection();
|
|
20289
21657
|
const handleMoveInEditor = (keycode, metaKey) => {
|
|
20290
21658
|
if (onMoveInEditorRef.current) {
|
|
@@ -20331,7 +21699,7 @@ const useLeftAndRightArrow = (isNeed, selectingMode, editor, onMoveInEditor) =>
|
|
|
20331
21699
|
return {
|
|
20332
21700
|
id: operationId,
|
|
20333
21701
|
binding: metaKey ? keyCode | metaKey : keyCode,
|
|
20334
|
-
preconditions: () =>
|
|
21702
|
+
preconditions: () => editor.isFocus(),
|
|
20335
21703
|
priority: 900,
|
|
20336
21704
|
staticParameters: {
|
|
20337
21705
|
eventType: DeviceInputEventType.Keyboard,
|
|
@@ -20349,6 +21717,7 @@ const useLeftAndRightArrow = (isNeed, selectingMode, editor, onMoveInEditor) =>
|
|
|
20349
21717
|
commandService,
|
|
20350
21718
|
editor,
|
|
20351
21719
|
isNeed,
|
|
21720
|
+
operationId,
|
|
20352
21721
|
shortcutService
|
|
20353
21722
|
]);
|
|
20354
21723
|
};
|
|
@@ -20610,4 +21979,4 @@ const RichTextEditor = (props) => {
|
|
|
20610
21979
|
};
|
|
20611
21980
|
|
|
20612
21981
|
//#endregion
|
|
20613
|
-
export { AfterSpaceCommand, AlignCenterCommand, AlignJustifyCommand, AlignLeftCommand, AlignMenuItemFactory, AlignOperationCommand, AlignRightCommand, BackgroundColorSelectorMenuItemFactory, BoldMenuItemFactory, BreakLineCommand, BulletListCommand, ChangeListNestingLevelCommand, ChangeListNestingLevelType, ChangeListTypeCommand, CheckListCommand, CoverContentCommand, CreateDocTableCommand, CutContentCommand, DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX, DOCS_COMPONENT_DEFAULT_Z_INDEX, DOCS_COMPONENT_HEADER_LAYER_INDEX, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_VIEW_KEY, DOC_CONTENT_INSERT_MENU_ID, DOC_PARAGRAPH_T_ALIGN_MENU_ID, DOC_PARAGRAPH_T_COLORS_MENU_ID, DOC_PARAGRAPH_T_DIVIDER_MENU_ID, DOC_PARAGRAPH_T_EDIT_MENU_ID, DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID, DOC_PARAGRAPH_T_INSERT_MENU_ID, DOC_TABLE_BLOCK_MENU_ID, DOC_VERTICAL_PADDING, DeleteCurrentParagraphCommand, DeleteCustomBlockCommand, DeleteLeftCommand, DeleteRightCommand, DocAutoFormatService, DocBackScrollRenderController, DocCanvasPopManagerService, DocCopyCommand, DocCreateTableOperation, DocCutCommand, DocEventManagerService, DocHtmlExportService, DocIMEInputManagerService, DocParagraphMenuService, DocParagraphPlaceholderRenderController, DocPasteCommand, DocPrintInterceptorService, DocRenderController, DocSelectAllCommand, DocSelectionRenderService, DocTableDeleteColumnsCommand, DocTableDeleteRowsCommand, DocTableDeleteTableCommand, DocTableInsertColumnCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, DocTableInsertRowCommand, DocTableTabCommand, DocUIController, DocViewScaleService, DocsRenderService, menuSchema as DocsUIMenuSchema, EMPTY_PARAGRAPH_MENU_ID, Editor, EditorService, EnterCommand, FLOAT_TEXT_STYLE_MENU_ID, FLOAT_TOOLBAR_MENU_POSITION, FloatTextStyleMenuItemFactory, FontFamilySelectorMenuItemFactory, FontSizeSelectorMenuItemFactory, HorizontalLineCommand, IDocClipboardService, IEditorService, IMEInputCommand, INSERT_BELLOW_MENU_ID, InnerPasteCommand, InsertCustomRangeCommand, ItalicMenuItemFactory, ListOperationCommand, MergeTwoParagraphCommand, MoveCursorOperation, MoveDocBlockCommand, MoveSelectionOperation, NORMAL_TEXT_SELECTION_PLUGIN_NAME, NodePositionConvertToCursor, NodePositionConvertToRectRange, OrderListCommand, ParagraphMenuInsertBelowSubmenuItemFactory, LarkPastePlugin as PastePluginLark, UniverPastePlugin as PastePluginUniver, WordPastePlugin as PastePluginWord, QuickListCommand, RectRange, ReplaceContentCommand, ReplaceSelectionCommand, ReplaceSnapshotCommand, ReplaceTextRunsCommand, ResetInlineFormatTextBackgroundColorCommand, ResetInlineFormatTextColorCommand, RichTextEditor, SetDocZoomRatioCommand, SetDocZoomRatioOperation, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand, SetInlineFormatTextFillCommand, SetInlineFormatUnderlineCommand, SetParagraphNamedStyleCommand, StrikeThroughMenuItemFactory, SwitchDocModeCommand, TEXT_RANGE_LAYER_INDEX, TabCommand, TextColorSelectorMenuItemFactory, TextRange, ToggleCheckListCommand, UnderlineMenuItemFactory, UniverDocsUIPlugin, VIEWPORT_KEY, addCustomDecorationBySelectionFactory, addCustomDecorationFactory, buildMoveDocBlockActions, calcDocFitToWidthScale, calcDocRangePositions, convertBodyToHtml, convertPositionsToRectRanges, createEditorUndoRedoKeyboardConfig, deleteCustomDecorationFactory, disableMenuWhenHeaderFooterEditing, docDrawingPositionToTransform, executeEditorUndoRedoCommand, genTableSource, generateParagraphs, getAnchorBounding, getCanvasOffsetByEngine, getCommandSkeleton, getCursorWhenDelete, getCustomBlockIdsInSelections, getCutActionsFromDocRanges, getDocBlockRangeMenuId, getDocObject, getDocObjectById, getEmptyTableCell, getEmptyTableRow, getLineBounding, getListMarkerFallbackBound, getListParagraphContextMenuHit, getOneTextSelectionRange, getStyleInTextRange, getTableColumn, hasParagraphInTable, hideMenuWhenSelectionInBlockRange, isInSameTableCell, isTextRangeInAnyBlockRange, isValidRectRange, neoGetDocObject, normalizeDocFitToWidthOptions, resolveDocFitBaseWidth, resolveDocViewScale, transformToDocDrawingPosition, useEditor, useEditorClickOutside, useIsFocusing, useKeyboardEvent, useLeftAndRightArrow, useOnChange, useResize, whenDocAndEditorFocused };
|
|
21982
|
+
export { AfterSpaceCommand, AlignCenterCommand, AlignJustifyCommand, AlignLeftCommand, AlignMenuItemFactory, AlignOperationCommand, AlignRightCommand, BackgroundColorSelectorMenuItemFactory, BoldMenuItemFactory, BreakLineCommand, BulletListCommand, ChangeListNestingLevelCommand, ChangeListNestingLevelType, ChangeListTypeCommand, CheckListCommand, CoverContentCommand, CreateDocTableCommand, CutContentCommand, DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX, DOCS_COMPONENT_DEFAULT_Z_INDEX, DOCS_COMPONENT_HEADER_LAYER_INDEX, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_UI_PLUGIN_CONFIG_KEY, DOCS_VIEW_KEY, DOC_CONTENT_INSERT_MENU_ID, DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, DOC_PARAGRAPH_T_ALIGN_MENU_ID, DOC_PARAGRAPH_T_COLORS_MENU_ID, DOC_PARAGRAPH_T_DIVIDER_MENU_ID, DOC_PARAGRAPH_T_EDIT_MENU_ID, DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID, DOC_PARAGRAPH_T_INSERT_MENU_ID, DOC_TABLE_BLOCK_MENU_ID, DOC_VERTICAL_PADDING, DeleteCurrentParagraphCommand, DeleteCustomBlockCommand, DeleteLeftCommand, DeleteRightCommand, DocAutoFormatService, DocBackScrollRenderController, DocCanvasPopManagerService, DocClipboardPasteAdapterService, DocCopyCommand, DocCreateTableOperation, DocCutCommand, DocEventManagerService, DocFloatMenuService, DocHtmlExportService, DocIMEInputManagerService, DocPageLayoutService, DocParagraphMenuService, DocParagraphPlaceholderRenderController, DocPasteCommand, DocPrintInterceptorService, DocRenderController, DocSelectAllCommand, DocSelectionRenderService, DocTableDeleteColumnsCommand, DocTableDeleteRowsCommand, DocTableDeleteTableCommand, DocTableInsertColumnCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, DocTableInsertRowCommand, DocTableTabCommand, DocUIController, DocViewScaleService, DocsRenderService, menuSchema as DocsUIMenuSchema, EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY, EMPTY_PARAGRAPH_MENU_ID, Editor, EditorService, EnterCommand, FLOAT_TEXT_STYLE_MENU_ID, FLOAT_TOOLBAR_MENU_POSITION, FloatTextStyleMenuItemFactory, FontFamilySelectorMenuItemFactory, FontSizeSelectorMenuItemFactory, HorizontalLineCommand, IDocClipboardPasteAdapterService, IDocClipboardService, IDocEmbedInteractionBoundaryService, IDocEmbedRuntimeFocusCoordinator, IEditorService, IMEInputCommand, INSERT_BELLOW_MENU_ID, InnerPasteCommand, InsertCustomRangeCommand, ItalicMenuItemFactory, ListOperationCommand, MergeTwoParagraphCommand, MoveCursorOperation, MoveDocBlockCommand, MoveSelectionOperation, NORMAL_TEXT_SELECTION_PLUGIN_NAME, NodePositionConvertToCursor, NodePositionConvertToRectRange, OrderListCommand, ParagraphMenuInsertBelowSubmenuItemFactory, LarkPastePlugin as PastePluginLark, UniverPastePlugin as PastePluginUniver, WordPastePlugin as PastePluginWord, QuickListCommand, RectRange, ReplaceContentCommand, ReplaceSelectionCommand, ReplaceSnapshotCommand, ReplaceTextRunsCommand, ResetInlineFormatTextBackgroundColorCommand, ResetInlineFormatTextColorCommand, RichTextEditor, SetDocZoomRatioCommand, SetDocZoomRatioOperation, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand, SetInlineFormatTextFillCommand, SetInlineFormatUnderlineCommand, SetParagraphNamedStyleCommand, StrikeThroughMenuItemFactory, SwitchDocModeCommand, TEXT_RANGE_LAYER_INDEX, TabCommand, TextColorSelectorMenuItemFactory, TextRange, ToggleCheckListCommand, UnderlineMenuItemFactory, UniverDocsUIPlugin, VIEWPORT_KEY, addCustomDecorationBySelectionFactory, addCustomDecorationFactory, buildMoveDocBlockActions, calcDocFitToWidthScale, calcDocRangePositions, collectDocsTableLikeEmbedChildUnitIds, convertBodyToHtml, convertPositionsToRectRanges, createDefaultDocsTableLikeCustomBlockBleedViewport, createDocsCustomBlockInsertMutation, createDocsCustomBlockRemoveMutation, createDocsCustomBlockSizeRefreshScheduler, createEditorUndoRedoKeyboardConfig, createEmbedDocsCustomBlockData, createInsertCustomBlockActions, createRemoveCustomBlockActions, deleteCustomDecorationFactory, disableMenuWhenHeaderFooterEditing, docDrawingPositionToTransform, executeEditorUndoRedoCommand, genTableSource, generateParagraphs, getAnchorBounding, getCanvasOffsetByEngine, getCommandSkeleton, getCursorWhenDelete, getCustomBlockIdsInSelections, getCutActionsFromDocRanges, getDocBlockRangeMenuId, getDocObject, getDocObjectById, getEmptyTableCell, getEmptyTableRow, getLineBounding, getListMarkerFallbackBound, getListParagraphContextMenuHit, getOneTextSelectionRange, getStyleInTextRange, getTableColumn, hasParagraphInTable, hideMenuWhenSelectionInBlockRange, isInSameTableCell, isSheetLikeDocsCustomBlockChildType, isTextRangeInAnyBlockRange, isValidRectRange, neoGetDocObject, normalizeDocFitToWidthOptions, resolveDocFitBaseWidth, resolveDocViewScale, resolveDocsCustomBlockRenderViewport, resolveDocsCustomBlockSize, resolveDocsTableLikeCustomBlockBleedViewport, resolveDocsTableLikeCustomBlockContentHeight, resolveDocsTableLikeCustomBlockContentWidth, scrollDocsTableLikeCustomBlockLive, shouldRefreshDocsCustomBlockSizeForCommand, transformToDocDrawingPosition, useEditor, useEditorClickOutside, useIsFocusing, useKeyboardEvent, useLeftAndRightArrow, useOnChange, useResize, whenDocAndEditorFocused };
|