@univerjs/docs-ui 1.0.3 → 1.0.4
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 +1189 -284
- package/lib/cjs/locale/ar-SA.js +12 -0
- package/lib/cjs/locale/ca-ES.js +12 -0
- package/lib/cjs/locale/de-DE.js +12 -0
- package/lib/cjs/locale/en-US.js +12 -0
- package/lib/cjs/locale/es-ES.js +12 -0
- package/lib/cjs/locale/fa-IR.js +12 -0
- package/lib/cjs/locale/fr-FR.js +12 -0
- package/lib/cjs/locale/id-ID.js +12 -0
- package/lib/cjs/locale/it-IT.js +12 -0
- package/lib/cjs/locale/ja-JP.js +12 -0
- package/lib/cjs/locale/ko-KR.js +12 -0
- package/lib/cjs/locale/pl-PL.js +12 -0
- package/lib/cjs/locale/pt-BR.js +12 -0
- package/lib/cjs/locale/ru-RU.js +12 -0
- package/lib/cjs/locale/sk-SK.js +12 -0
- package/lib/cjs/locale/vi-VN.js +12 -0
- package/lib/cjs/locale/zh-CN.js +12 -0
- package/lib/cjs/locale/zh-HK.js +12 -0
- package/lib/cjs/locale/zh-TW.js +12 -0
- package/lib/es/index.js +1194 -289
- package/lib/es/locale/ar-SA.js +12 -0
- package/lib/es/locale/ca-ES.js +12 -0
- package/lib/es/locale/de-DE.js +12 -0
- package/lib/es/locale/en-US.js +12 -0
- package/lib/es/locale/es-ES.js +12 -0
- package/lib/es/locale/fa-IR.js +12 -0
- package/lib/es/locale/fr-FR.js +12 -0
- package/lib/es/locale/id-ID.js +12 -0
- package/lib/es/locale/it-IT.js +12 -0
- package/lib/es/locale/ja-JP.js +12 -0
- package/lib/es/locale/ko-KR.js +12 -0
- package/lib/es/locale/pl-PL.js +12 -0
- package/lib/es/locale/pt-BR.js +12 -0
- package/lib/es/locale/ru-RU.js +12 -0
- package/lib/es/locale/sk-SK.js +12 -0
- package/lib/es/locale/vi-VN.js +12 -0
- package/lib/es/locale/zh-CN.js +12 -0
- package/lib/es/locale/zh-HK.js +12 -0
- package/lib/es/locale/zh-TW.js +12 -0
- package/lib/index.css +21 -0
- package/lib/index.js +1194 -289
- package/lib/locale/ar-SA.js +12 -0
- package/lib/locale/ca-ES.js +12 -0
- package/lib/locale/de-DE.js +12 -0
- package/lib/locale/en-US.js +12 -0
- package/lib/locale/es-ES.js +12 -0
- package/lib/locale/fa-IR.js +12 -0
- package/lib/locale/fr-FR.js +12 -0
- package/lib/locale/id-ID.js +12 -0
- package/lib/locale/it-IT.js +12 -0
- package/lib/locale/ja-JP.js +12 -0
- package/lib/locale/ko-KR.js +12 -0
- package/lib/locale/pl-PL.js +12 -0
- package/lib/locale/pt-BR.js +12 -0
- package/lib/locale/ru-RU.js +12 -0
- package/lib/locale/sk-SK.js +12 -0
- package/lib/locale/vi-VN.js +12 -0
- package/lib/locale/zh-CN.js +12 -0
- package/lib/locale/zh-HK.js +12 -0
- package/lib/locale/zh-TW.js +12 -0
- package/lib/types/commands/commands/doc-delete.command.d.ts +5 -2
- package/lib/types/commands/commands/doc-header-footer.command.d.ts +2 -0
- package/lib/types/commands/commands/insert-header-footer-field.command.d.ts +28 -0
- package/lib/types/commands/commands/refresh-header-footer-fields.command.d.ts +22 -0
- package/lib/types/commands/operations/doc-header-footer-ribbon.operation.d.ts +19 -0
- package/lib/types/controllers/doc-header-footer-ribbon.controller.d.ts +31 -0
- package/lib/types/controllers/render-controllers/doc-field.render-controller.d.ts +31 -0
- package/lib/types/controllers/ui.controller.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +12 -0
- package/lib/types/menu/header-footer-ribbon.d.ts +17 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +4 -0
- package/lib/types/services/doc-event-manager.service.d.ts +1 -0
- package/lib/types/services/selection/doc-selection-render.service.d.ts +2 -0
- package/lib/types/services/selection/word-boundary.d.ts +1 -0
- package/lib/types/shortcuts/core-editing.shortcut.d.ts +4 -0
- package/lib/types/shortcuts/format.shortcut.d.ts +1 -0
- package/lib/types/shortcuts/utils.d.ts +1 -0
- package/lib/types/utils/date-time-field.d.ts +22 -0
- package/lib/types/views/header-footer/panel/DocHeaderFooterFields.d.ts +19 -0
- package/lib/types/views/header-footer/panel/DocHeaderFooterRibbonControl.d.ts +20 -0
- package/lib/types/views/header-footer/panel/component-name.d.ts +2 -0
- package/lib/types/views/header-footer/panel/use-header-footer-options.d.ts +2 -2
- package/lib/umd/index.js +15 -14
- 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 -10
package/lib/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { BaselineOffset, BlockType, BooleanNumber, BuildTextUtils, COLORS, ColorKit, ColumnSeparatorType, CommandType, CustomDecorationType, 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, ErrorService, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_DOC, FOCUSING_EDITOR_STANDALONE, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_UNIVER_EDITOR, HorizontalAlign, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IUndoRedoService, IUniverInstanceService, ImageSourceType, Inject, Injector, InterceptorManager, JSON1, JSONX, LOCALE_META, LRUMap, ListGlyphType, LocaleService, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MemoryCursor, ModernDocumentWidthMode, NAMED_STYLE_MAP, NamedStyleType, ObjectPermissionService, ObjectRelativeFromH, ObjectRelativeFromV, Optional, PAGE_SIZE, PAPER_TYPES, PRESERVE_INSERTED_PARAGRAPH_IDS, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, PresetListType, QuickListTypeMap, RANGE_DIRECTION, Rectangle, RedoCommand, RegionService, RichTextBuilder, RxDisposable, SHEET_EDITOR_UNITS, SectionType, SliceBodyType, SpacingRule, TableAlignmentType, TableRowHeightRule, TableSizeType, TableTextWrapType, TextX, TextXActionType, ThemeService, Tools, UndoCommand, UniverInstanceType, UpdateDocsAttributeType, VerticalAlign, checkForSubstrings, cloneBodyWithFreshParagraphIds, containsInteriorInsertionOffset, createIdentifier, createInterceptorKey, createInternalEditorID, createParagraphId, createSectionId, debounce, fromEventSubject, generateRandomId, getBlockRangeInterval, getBodySlice, getBodySliceForTextXAction, getColorStyle, getCustomBlockIdsInSelections, getParagraphContentStartOffset, getParagraphContentStartOffsets, getPlainText, getRichTextEditPath, getSectionHeaderFooterReferenceKey, getTableRangeInterval, getTextRunSlice, isCommentEditorID, isInternalEditorID, isSafeUrl, merge, mergeOverrideWithDependencies, normalizeBody, remove, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReference, resolveSectionHeaderFooterReferences, sequenceExecuteAsync, skipParseTagNames, toDisposable, touchDependencies, validateDocBodyStructure } from "@univerjs/core";
|
|
2
|
-
import { CreateHeaderFooterCommand, DeleteTextCommand, DocBlockMoveValidatorService, DocContentInsertService, DocHistoryAction, DocInterceptorService, DocLayoutExecutorService, DocLayoutExecutorState, DocLayoutSessionStatus, DocSelectionManagerService, DocSkeletonManagerService, DocStateChangeManagerService, DocStateEmitService, HeaderFooterType, IDocStateChangeInterceptorService, InsertDocumentColumnBreakCommand, InsertDocumentSectionBreakCommand, InsertTextCommand, RichTextEditingMutation, SetDocumentPermissionCommand, SetSectionHeaderFooterLinkCommand, SetTextSelectionsOperation, UniverDocsPlugin, UpdateDocumentSectionCommand, UpdateTextCommand, buildDocTransform, canEditDocumentTargets, consumeContentInsertRange, createSectionColumnProperties, generateParagraphs, getDocumentEditTargetObjectIds, getDocumentParagraphPermissionObjectId, getDocumentPermissionValue, getDocumentSectionPermissionObjectId, getTopLevelSectionBreaks, isSheetLikeDocsCustomBlockChildType, resolveDocsCustomBlockSize, shouldUseInlineTextSelectionForDocsCustomBlockDrawing } from "@univerjs/docs";
|
|
1
|
+
import { BaselineOffset, BlockType, BooleanNumber, BuildTextUtils, COLORS, ColorKit, ColumnSeparatorType, CommandType, CustomDecorationType, 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, ErrorService, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_DOC, FOCUSING_EDITOR_STANDALONE, FOCUSING_FX_BAR_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_UNIVER_EDITOR, HorizontalAlign, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IUndoRedoService, IUniverInstanceService, ImageSourceType, Inject, Injector, InterceptorManager, JSON1, JSONX, LOCALE_META, LRUMap, ListGlyphType, LocaleService, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MemoryCursor, ModernDocumentWidthMode, NAMED_STYLE_MAP, NamedStyleType, ObjectPermissionService, ObjectRelativeFromH, ObjectRelativeFromV, Optional, PAGE_SIZE, PAPER_TYPES, PRESERVE_INSERTED_PARAGRAPH_IDS, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, PresetListType, QuickListTypeMap, RANGE_DIRECTION, Rectangle, RedoCommand, RegionService, RichTextBuilder, RxDisposable, SHEET_EDITOR_UNITS, SectionType, SliceBodyType, SpacingRule, TableAlignmentType, TableRowHeightRule, TableSizeType, TableTextWrapType, TextX, TextXActionType, ThemeService, Tools, UndoCommand, UniverInstanceType, UpdateDocsAttributeType, VerticalAlign, checkForSubstrings, cloneBodyWithFreshParagraphIds, containsInteriorInsertionOffset, createIdentifier, createInterceptorKey, createInternalEditorID, createParagraphId, createSectionId, debounce, fromEventSubject, generateRandomId, getBlockRangeInterval, getBodySlice, getBodySliceForTextXAction, getColorStyle, getCustomBlockIdsInSelections, getParagraphContentStartOffset, getParagraphContentStartOffsets, getPlainText, getRichTextEditPath, getSectionHeaderFooterReferenceKey, getTableRangeInterval, getTextRunSlice, isCommentEditorID, isInternalEditorID, isSafeUrl, merge, mergeOverrideWithDependencies, normalizeBody, remove, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReference, resolveSectionHeaderFooterReferences, sequenceExecuteAsync, skipParseTagNames, toDisposable, touchDependencies, validateDocBodyStructure } from "@univerjs/core";
|
|
2
|
+
import { CreateHeaderFooterCommand, DeleteTextCommand, DocBlockMoveValidatorService, DocContentInsertService, DocHistoryAction, DocInterceptorService, DocLayoutExecutorService, DocLayoutExecutorState, DocLayoutSessionStatus, DocSelectionManagerService, DocSkeletonManagerService, DocStateChangeManagerService, DocStateEmitService, HeaderFooterType, IDocStateChangeInterceptorService, InsertDocumentColumnBreakCommand, InsertDocumentSectionBreakCommand, InsertTextCommand, RichTextEditingMutation, SetDocumentPermissionCommand, SetSectionHeaderFooterLinkCommand, SetTextSelectionsOperation, UniverDocsPlugin, UpdateDocumentSectionCommand, UpdateTextCommand, buildDocTransform, canEditDocumentTargets, consumeContentInsertRange, createSectionColumnProperties, generateParagraphs, getDocumentEditTargetObjectIds, getDocumentParagraphPermissionObjectId, getDocumentPermissionValue, getDocumentSectionPermissionObjectId, getTopLevelSectionBreaks, isSheetLikeDocsCustomBlockChildType, resolveDocsCustomBlockSize, shouldUseInlineTextSelectionForDocsCustomBlockDrawing, transformDocumentTextRanges } from "@univerjs/docs";
|
|
3
3
|
import * as EngineRender from "@univerjs/engine-render";
|
|
4
4
|
import { BaseObject, CURSOR_TYPE, DRAWING_OBJECT_UPPER_LAYER_INDEX, DeviceInputEventType, DocBackground, DocumentEditArea, DocumentSkeletonPageType, Documents, GlyphType, IRenderManagerService, Layer, LineType, Liquid, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, PageLayoutType, Path, RENDER_CLASS_TYPE, Rect, RegularPolygon, ScrollBar, ScrollTimer, Shape, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin, Vector2, Viewport, compareDocumentSkeletonNestedPagePathOrder, documentSkeletonLineIterator, documentSkeletonTableIterator, getColor, getDocsTableRenderViewport, getDocsTableViewportLeft, getDocumentSkeletonColumnPagePathInfo, getDocumentSkeletonNestedPageOffset, getLastColumn, getNextWheelZoomRatio, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getSystemHighlightColor, getTableIdAndSliceIndex, getTopmostDocsTableHit, hasListGlyph, isFirstGlyph, isIndentByGlyph, parseDataStreamToTree, pixelToPt, ptToPixel, pxToNum, registerDocumentLayoutPresentation } from "@univerjs/engine-render";
|
|
5
|
-
import { Button, Checkbox, Dropdown, DropdownMenu, InputNumber, MessageType, MobileSelect, Popup, Select, Separator, Tooltip, borderClassName, clsx, resetButtonClassName, scrollbarClassName, useMobileKeyboardViewportLayout } from "@univerjs/design";
|
|
5
|
+
import { Button, Checkbox, Dialog, Dropdown, DropdownMenu, InputNumber, MessageType, MobileSelect, Popup, Select, Separator, Tooltip, borderClassName, clsx, resetButtonClassName, scrollbarClassName, selectClassName, useMobileKeyboardViewportLayout } from "@univerjs/design";
|
|
6
6
|
import { BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, ComponentManager, ContextMenuGroup, ContextMenuPanel, ContextMenuPosition, CopyCommand, CutCommand, EMOJI_PICKER_COMPONENT, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FormatPainterSessionService, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, ILayoutService, IMenuManagerService, IMessageService, IRibbonService, IShortcutService, ISidebarService, IUIPartsService, IWorkbenchService, IconManager, KeyCode, MOBILE_UI_MODE, MenuItemType, MenuManagerPosition, MetaKeys, MobileDrawer, MobileKeyboardInsetContext, MobileMenu, MobileZoomIndicator, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RectPopup, RibbonInsertGroup, RibbonStartGroup, SYMBOL_PICKER_COMPONENT, Slider, ToolbarButton, ToolbarItem, UniverMobileUIPlugin, bindFormatPainterCanvas, connectInjector, getMenuHiddenObservable, getMobileCanvasPanDelta, imageMimeTypeSet, objectPermissionMenuItemFactory, openObjectPermissionDialog, openObjectPermissionPanel, preventBrowserZoomInContainers, useConfigValue, useDependency, useEvent, useInjector, useMobileCanvasPanel, useMobileCanvasViewport, useObservable } from "@univerjs/ui";
|
|
7
7
|
import { UnitAction, UnitObject } from "@univerjs/protocol";
|
|
8
8
|
import { BehaviorSubject, EMPTY, Observable, Subject, animationFrameScheduler, auditTime, combineLatest, debounceTime, distinctUntilChanged, filter, first, fromEvent, map, merge as merge$1, observeOn, of, shareReplay, startWith, switchMap, take, takeUntil, tap, throttleTime } from "rxjs";
|
|
9
9
|
import { bufferTime, filter as filter$1, map as map$1 } from "rxjs/operators";
|
|
10
|
-
import { createElement, forwardRef, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
10
|
+
import { createElement, forwardRef, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { AddImageIcon, AlignTextBothIcon, BoldIcon, CatalogueIcon, CheckMarkIcon, CloseIcon, ColorWheelMultiIcon, ColumnIcon, CopyDoubleIcon, CutIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DeleteTableDoubleIcon, DocPasteOptionsIcon, DocSettingIcon, DownIcon, FontColorDoubleIcon, GridIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, HeaderFooterIcon, HorizontallyIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, KeyboardIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LineIndentDecreaseIcon, LineIndentIncreaseIcon, LoadingMultiIcon, MenuIcon, MoreHorizontalIcon, MoreLeftIcon, MoreRightIcon, NoColorDoubleIcon, OrderIcon, PaintBucketDoubleIcon, ParagraphSettingIcon, PasteSpecialDoubleIcon, QuickAddIcon, ReduceDoubleIcon, ReduceIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, SectionSettingIcon, ShapeIcon, SmileIcon, StatisticalFunctionIcon, StrikethroughIcon, SubscriptIcon, SubtitleTypeIcon, SuperscriptIcon, SymbolsIcon, TextColorSwatchDoubleIcon, TextIcon, TextTypeIcon, TitleTypeIcon, TodoListDoubleIcon, UnderlineIcon, UnorderIcon, WriteIcon } from "@univerjs/icons";
|
|
12
|
+
import { AddImageIcon, AlignTextBothIcon, BoldIcon, CalendarIcon, CatalogueIcon, CheckMarkIcon, CloseIcon, ColorWheelMultiIcon, ColumnIcon, CopyDoubleIcon, CutIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DeleteTableDoubleIcon, DocPasteOptionsIcon, DocSettingIcon, DownIcon, FontColorDoubleIcon, GridIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, HeaderFooterIcon, HorizontallyIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, KeyboardIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LineIndentDecreaseIcon, LineIndentIncreaseIcon, LoadingMultiIcon, MenuIcon, MoreDownIcon, MoreHorizontalIcon, MoreLeftIcon, MoreRightIcon, NoColorDoubleIcon, NumberIcon, OrderIcon, PaintBucketDoubleIcon, ParagraphSettingIcon, PasteSpecialDoubleIcon, QuickAddIcon, ReduceDoubleIcon, ReduceIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, SectionSettingIcon, ShapeIcon, SmileIcon, StatisticalFunctionIcon, StrikethroughIcon, SubscriptIcon, SubtitleTypeIcon, SuperscriptIcon, SymbolsIcon, TextColorSwatchDoubleIcon, TextIcon, TextTypeIcon, TitleTypeIcon, TodoListDoubleIcon, UnderlineIcon, UnorderIcon, WriteIcon } from "@univerjs/icons";
|
|
13
13
|
import { getDrawingShapeKeyByDrawingSearch } from "@univerjs/drawing";
|
|
14
14
|
|
|
15
15
|
//#region src/basics/docs-view-key.ts
|
|
@@ -1643,10 +1643,10 @@ var NodePositionConvertToCursor = class {
|
|
|
1643
1643
|
let segmentPage = page;
|
|
1644
1644
|
if (pageType === DocumentSkeletonPageType.HEADER) {
|
|
1645
1645
|
var _skeHeaders$get;
|
|
1646
|
-
segmentPage = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(pageWidth);
|
|
1646
|
+
segmentPage = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(page.headerLayoutKey ?? pageWidth);
|
|
1647
1647
|
} else if (pageType === DocumentSkeletonPageType.FOOTER) {
|
|
1648
1648
|
var _skeFooters$get;
|
|
1649
|
-
segmentPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(pageWidth);
|
|
1649
|
+
segmentPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(page.footerLayoutKey ?? pageWidth);
|
|
1650
1650
|
} else if (pageType === DocumentSkeletonPageType.NOTE) {
|
|
1651
1651
|
var _getPageFromPath3, _page$notes;
|
|
1652
1652
|
const noteId = (_getPageFromPath3 = getPageFromPath(skeletonData, path)) === null || _getPageFromPath3 === void 0 ? void 0 : _getPageFromPath3.segmentId;
|
|
@@ -1813,8 +1813,8 @@ function getCellPageFromSegmentPath(skeletonData, rootPage, path) {
|
|
|
1813
1813
|
if (path[0] === "pages") return null;
|
|
1814
1814
|
const segmentPages = [];
|
|
1815
1815
|
const { headerId, footerId, pageWidth } = rootPage;
|
|
1816
|
-
const headerPage = headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(pageWidth);
|
|
1817
|
-
const footerPage = footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(pageWidth);
|
|
1816
|
+
const headerPage = headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(rootPage.headerLayoutKey ?? pageWidth);
|
|
1817
|
+
const footerPage = footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(rootPage.footerLayoutKey ?? pageWidth);
|
|
1818
1818
|
if (headerPage != null) segmentPages.push(headerPage);
|
|
1819
1819
|
if (footerPage != null) segmentPages.push(footerPage);
|
|
1820
1820
|
for (const segmentPage of segmentPages) {
|
|
@@ -2229,7 +2229,7 @@ function getCellPageFromPositionPath(skeletonData, position) {
|
|
|
2229
2229
|
const rootPage = skeletonData.pages[segmentPage];
|
|
2230
2230
|
if (rootPage == null) return null;
|
|
2231
2231
|
const { headerId, footerId, pageWidth } = rootPage;
|
|
2232
|
-
const segmentPages = [headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(pageWidth), footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(pageWidth)];
|
|
2232
|
+
const segmentPages = [headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(rootPage.headerLayoutKey ?? pageWidth), footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(rootPage.footerLayoutKey ?? pageWidth)];
|
|
2233
2233
|
for (const segmentPage of segmentPages) {
|
|
2234
2234
|
if (segmentPage == null) continue;
|
|
2235
2235
|
const page = getPageFromPath({
|
|
@@ -3169,6 +3169,20 @@ function getWordBoundaryByIndex(content, nodeIndex, paragraphStartOffset) {
|
|
|
3169
3169
|
endOffset: paragraphStartOffset + range.end
|
|
3170
3170
|
};
|
|
3171
3171
|
}
|
|
3172
|
+
function getWordSelectionByIndex(content, nodeIndex, paragraphStartOffset, isBack) {
|
|
3173
|
+
var _segments;
|
|
3174
|
+
const text = content.replace(/[\r\n]+$/, "");
|
|
3175
|
+
if (!text.length || nodeIndex < 0) return null;
|
|
3176
|
+
const index = Math.min(nodeIndex, text.length - 1);
|
|
3177
|
+
const segments = Array.from(new Intl.Segmenter(void 0, { granularity: "word" }).segment(text));
|
|
3178
|
+
const segmentIndex = segments.findIndex((segment) => segment.index <= index && index < segment.index + segment.segment.length);
|
|
3179
|
+
const segment = segments[segmentIndex];
|
|
3180
|
+
const whitespace = /^\s+$/.test(segment.segment);
|
|
3181
|
+
return {
|
|
3182
|
+
startOffset: paragraphStartOffset + (whitespace ? ((_segments = segments[segmentIndex - 1]) === null || _segments === void 0 ? void 0 : _segments.index) ?? segment.index : segment.index),
|
|
3183
|
+
endOffset: paragraphStartOffset + (whitespace ? Math.min(nodeIndex + (isBack ? 0 : 1), text.length) : segment.index + segment.segment.length)
|
|
3184
|
+
};
|
|
3185
|
+
}
|
|
3172
3186
|
function getNextWordBoundaryOffset(content, nodeIndex, paragraphStartOffset, direction) {
|
|
3173
3187
|
if (nodeIndex < 0) return null;
|
|
3174
3188
|
const ranges = getWordRanges(content);
|
|
@@ -3198,6 +3212,12 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
3198
3212
|
get isFocusing() {
|
|
3199
3213
|
return this._input === this._getOwnerDocument().activeElement;
|
|
3200
3214
|
}
|
|
3215
|
+
get inputElement() {
|
|
3216
|
+
return this._input;
|
|
3217
|
+
}
|
|
3218
|
+
get selectionContainer() {
|
|
3219
|
+
return this._container;
|
|
3220
|
+
}
|
|
3201
3221
|
get isEditing() {
|
|
3202
3222
|
var _this$_textSelectionI;
|
|
3203
3223
|
return ((_this$_textSelectionI = this._textSelectionInner$.value) === null || _this$_textSelectionI === void 0 ? void 0 : _this$_textSelectionI.isEditing) === true;
|
|
@@ -3331,15 +3351,13 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
3331
3351
|
this._selectionStyle = style;
|
|
3332
3352
|
}
|
|
3333
3353
|
replaceDocRanges(ranges, isEditing = true, options) {
|
|
3334
|
-
var _this$_context$unit$g;
|
|
3335
3354
|
if (this._onPointerEvent) {
|
|
3336
3355
|
this._pendingSelection = null;
|
|
3337
3356
|
return false;
|
|
3338
3357
|
}
|
|
3339
3358
|
this._syncNoteSegment(ranges[0]);
|
|
3340
|
-
const isBodyOrNote = this._currentSegmentId === "" || ((_this$_context$unit$g = this._context.unit.getSnapshot().notes) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g[this._currentSegmentId]) != null;
|
|
3341
3359
|
let currentLogicalSelection = null;
|
|
3342
|
-
if (
|
|
3360
|
+
if (ranges.length > 0) {
|
|
3343
3361
|
const { unitId } = this._context;
|
|
3344
3362
|
const selection = this._docSelectionManagerService.getSelectionInfo({
|
|
3345
3363
|
unitId,
|
|
@@ -3430,7 +3448,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
3430
3448
|
if (startNodePosition && endNodePosition) textRange = getTextRangeFromCharIndex(startNodePosition.isBack ? startOffset : startOffset - 1, endNodePosition.isBack ? endOffset : endOffset - 1, scene, document, docSkeleton, rangeStyle, segmentId, segmentPage, startNodePosition.isBack, endNodePosition.isBack);
|
|
3431
3449
|
else textRange = getTextRangeFromCharIndex(startOffset, endOffset, scene, document, docSkeleton, rangeStyle, segmentId, segmentPage);
|
|
3432
3450
|
if (textRange) this._addTextRange(textRange);
|
|
3433
|
-
} catch
|
|
3451
|
+
} catch {
|
|
3434
3452
|
generalAddRange(startOffset, endOffset, rangeStyle);
|
|
3435
3453
|
}
|
|
3436
3454
|
else generalAddRange(startOffset, endOffset, rangeStyle);
|
|
@@ -3520,7 +3538,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
3520
3538
|
if (paragraphInfo == null) return;
|
|
3521
3539
|
const { content, st, nodeIndex } = paragraphInfo;
|
|
3522
3540
|
if (nodeIndex === -1) return;
|
|
3523
|
-
const wordBoundary = getWordBoundaryByIndex(content, nodeIndex, st);
|
|
3541
|
+
const wordBoundary = this._context.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY || this._context.unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY ? getWordSelectionByIndex(content, nodeIndex, st, startNode.ratioX < .5) : getWordBoundaryByIndex(content, nodeIndex, st);
|
|
3524
3542
|
if (wordBoundary != null) {
|
|
3525
3543
|
this.removeAllRanges();
|
|
3526
3544
|
const textRanges = [{
|
|
@@ -4109,10 +4127,26 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
|
|
|
4109
4127
|
}));
|
|
4110
4128
|
}
|
|
4111
4129
|
_refreshMissingInputRange(config) {
|
|
4130
|
+
var _this$_context$unit$g;
|
|
4112
4131
|
if (config.activeRange == null) {
|
|
4113
4132
|
config.activeRange = this._getActiveRange();
|
|
4114
4133
|
config.rangeList = this._getAllTextRanges();
|
|
4115
4134
|
}
|
|
4135
|
+
const { unitId } = this._context;
|
|
4136
|
+
if (config.activeRange != null || unitId !== DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY || ((_this$_context$unit$g = this._context.unit.getBody()) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.dataStream) !== "\r\n") return;
|
|
4137
|
+
const selection = this._docSelectionManagerService.getSelectionInfo({
|
|
4138
|
+
unitId,
|
|
4139
|
+
subUnitId: unitId
|
|
4140
|
+
});
|
|
4141
|
+
if (selection == null || selection.textRanges.length !== 1 || selection.rectRanges.length > 0) return;
|
|
4142
|
+
const caret = selection.textRanges[0];
|
|
4143
|
+
if (!caret.isActive || caret.startOffset !== 0 || caret.endOffset !== 0) return;
|
|
4144
|
+
config.activeRange = {
|
|
4145
|
+
...caret,
|
|
4146
|
+
segmentId: selection.segmentId,
|
|
4147
|
+
segmentPage: selection.segmentPage
|
|
4148
|
+
};
|
|
4149
|
+
config.rangeList = [config.activeRange];
|
|
4116
4150
|
}
|
|
4117
4151
|
_handleInputFocus(event) {
|
|
4118
4152
|
this._eventHandle(event, (config) => {
|
|
@@ -5657,7 +5691,7 @@ const CutContentCommand = {
|
|
|
5657
5691
|
id: "doc.command.inner-cut",
|
|
5658
5692
|
type: CommandType.COMMAND,
|
|
5659
5693
|
handler: (accessor, params) => {
|
|
5660
|
-
var _selectionInfo$option3;
|
|
5694
|
+
var _selectionInfo$option3, _docDataModel$getSelf7;
|
|
5661
5695
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
5662
5696
|
const commandService = accessor.get(ICommandService);
|
|
5663
5697
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
@@ -5677,12 +5711,19 @@ const CutContentCommand = {
|
|
|
5677
5711
|
const docSkeletonManagerService = getCommandSkeleton(accessor, unitId);
|
|
5678
5712
|
if (docSkeletonManagerService == null) return false;
|
|
5679
5713
|
const viewModel = docSkeletonManagerService.getViewModel();
|
|
5714
|
+
const body = (_docDataModel$getSelf7 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf7 === void 0 ? void 0 : _docDataModel$getSelf7.getBody();
|
|
5715
|
+
const clearsBody = wholeBodySelected || body != null && isWholeBodySelected(selections, rectRanges, body);
|
|
5680
5716
|
const doMutation = {
|
|
5681
5717
|
id: RichTextEditingMutation.id,
|
|
5682
5718
|
params: {
|
|
5683
5719
|
unitId,
|
|
5684
5720
|
actions: [],
|
|
5685
|
-
textRanges
|
|
5721
|
+
textRanges: clearsBody ? [{
|
|
5722
|
+
...textRanges[0],
|
|
5723
|
+
startOffset: 0,
|
|
5724
|
+
endOffset: 0,
|
|
5725
|
+
collapsed: true
|
|
5726
|
+
}] : textRanges,
|
|
5686
5727
|
trigger: CutContentCommand.id
|
|
5687
5728
|
}
|
|
5688
5729
|
};
|
|
@@ -5699,6 +5740,31 @@ function isHorizontalLineParagraph(dataStream, paragraph) {
|
|
|
5699
5740
|
return Array.from(dataStream).every((token) => token === DataStreamTreeTokenType.PARAGRAPH || token === DataStreamTreeTokenType.SECTION_BREAK) && (paragraphStyle === null || paragraphStyle === void 0 ? void 0 : paragraphStyle.borderBottom) != null && paragraphStyle.borderTop == null && paragraphStyle.borderLeft == null && paragraphStyle.borderRight == null && paragraphStyle.borderBetween == null;
|
|
5700
5741
|
}
|
|
5701
5742
|
|
|
5743
|
+
//#endregion
|
|
5744
|
+
//#region src/commands/operations/doc-cursor.operation.ts
|
|
5745
|
+
/**
|
|
5746
|
+
* The operation to move cursor in the current document.
|
|
5747
|
+
*/
|
|
5748
|
+
const MoveCursorOperation = {
|
|
5749
|
+
id: "doc.operation.move-cursor",
|
|
5750
|
+
type: CommandType.OPERATION,
|
|
5751
|
+
handler: (accessor, params) => {
|
|
5752
|
+
if (!params) return false;
|
|
5753
|
+
return true;
|
|
5754
|
+
}
|
|
5755
|
+
};
|
|
5756
|
+
/**
|
|
5757
|
+
* The operation to move selection in the current document.
|
|
5758
|
+
*/
|
|
5759
|
+
const MoveSelectionOperation = {
|
|
5760
|
+
id: "doc.operation.move-selection",
|
|
5761
|
+
type: CommandType.OPERATION,
|
|
5762
|
+
handler: (accessor, params) => {
|
|
5763
|
+
if (!params) return false;
|
|
5764
|
+
return true;
|
|
5765
|
+
}
|
|
5766
|
+
};
|
|
5767
|
+
|
|
5702
5768
|
//#endregion
|
|
5703
5769
|
//#region src/commands/commands/format-painter.command.ts
|
|
5704
5770
|
function captureTextFormat(body, range, defaultStyle = {}, lists = {}, document = { documentStyle: {} }) {
|
|
@@ -6112,11 +6178,25 @@ function isDeleteOffsetInsideBlockRange(body, offset) {
|
|
|
6112
6178
|
return interval.startOffset < offset && offset < interval.endOffset - 1;
|
|
6113
6179
|
})) ?? false;
|
|
6114
6180
|
}
|
|
6181
|
+
function selectDeleteBoundary(accessor, direction, granularity) {
|
|
6182
|
+
var _selections$getActive, _selections$getRectRa;
|
|
6183
|
+
const selections = accessor.get(DocSelectionManagerService);
|
|
6184
|
+
if (((_selections$getActive = selections.getActiveTextRange()) === null || _selections$getActive === void 0 ? void 0 : _selections$getActive.collapsed) && !((_selections$getRectRa = selections.getRectRanges()) === null || _selections$getRectRa === void 0 ? void 0 : _selections$getRectRa.length)) {
|
|
6185
|
+
var _selections$getActive2;
|
|
6186
|
+
accessor.get(ICommandService).syncExecuteCommand(MoveSelectionOperation.id, {
|
|
6187
|
+
direction,
|
|
6188
|
+
granularity
|
|
6189
|
+
});
|
|
6190
|
+
return ((_selections$getActive2 = selections.getActiveTextRange()) === null || _selections$getActive2 === void 0 ? void 0 : _selections$getActive2.collapsed) === false;
|
|
6191
|
+
}
|
|
6192
|
+
return true;
|
|
6193
|
+
}
|
|
6115
6194
|
const DeleteLeftCommand = {
|
|
6116
6195
|
id: "doc.command.delete-left",
|
|
6117
6196
|
type: CommandType.COMMAND,
|
|
6118
|
-
handler: async (accessor) => {
|
|
6197
|
+
handler: async (accessor, params) => {
|
|
6119
6198
|
var _docDataModel$getSelf3, _docDataModel$getSelf4;
|
|
6199
|
+
if ((params === null || params === void 0 ? void 0 : params.granularity) && !selectDeleteBoundary(accessor, Direction.LEFT, params.granularity)) return true;
|
|
6120
6200
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
6121
6201
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
6122
6202
|
const commandService = accessor.get(ICommandService);
|
|
@@ -6276,8 +6356,9 @@ const DeleteLeftCommand = {
|
|
|
6276
6356
|
const DeleteRightCommand = {
|
|
6277
6357
|
id: "doc.command.delete-right",
|
|
6278
6358
|
type: CommandType.COMMAND,
|
|
6279
|
-
handler: async (accessor) => {
|
|
6359
|
+
handler: async (accessor, params) => {
|
|
6280
6360
|
var _docDataModel$getSelf5;
|
|
6361
|
+
if ((params === null || params === void 0 ? void 0 : params.granularity) && !selectDeleteBoundary(accessor, Direction.RIGHT, params.granularity)) return true;
|
|
6281
6362
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
6282
6363
|
const docDataModel = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
6283
6364
|
if (!docDataModel) return false;
|
|
@@ -8498,7 +8579,11 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
8498
8579
|
_defineProperty(this, "_umdToHtml", void 0);
|
|
8499
8580
|
this._umdToHtml = new UDMToHtmlService(docHtmlExportService);
|
|
8500
8581
|
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
8501
|
-
|
|
8582
|
+
var _command$params, _this$_pasteOptions$$;
|
|
8583
|
+
if (this._applyingPaste || command.type !== CommandType.MUTATION) return;
|
|
8584
|
+
const unitId = (_command$params = command.params) === null || _command$params === void 0 ? void 0 : _command$params.unitId;
|
|
8585
|
+
const pasteUnitId = ((_this$_pasteOptions$$ = this._pasteOptions$.value) === null || _this$_pasteOptions$$ === void 0 ? void 0 : _this$_pasteOptions$$.unitId) ?? this._getCurrentDocumentUnitId();
|
|
8586
|
+
if (!unitId || unitId === pasteUnitId) this.dismissPasteOptions();
|
|
8502
8587
|
}));
|
|
8503
8588
|
const invalidateSelection = () => {
|
|
8504
8589
|
const key = this._getPasteSelectionKey();
|
|
@@ -8572,6 +8657,12 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
8572
8657
|
mode
|
|
8573
8658
|
});
|
|
8574
8659
|
}
|
|
8660
|
+
isPasteOptionsEnabled(unitId) {
|
|
8661
|
+
return !isInternalEditorID(unitId) || this._clipboardHooks.some((hook) => {
|
|
8662
|
+
var _hook$supportsPasteOp;
|
|
8663
|
+
return (_hook$supportsPasteOp = hook.supportsPasteOptions) === null || _hook$supportsPasteOp === void 0 ? void 0 : _hook$supportsPasteOp.call(hook, unitId);
|
|
8664
|
+
});
|
|
8665
|
+
}
|
|
8575
8666
|
setNextPasteMode(mode) {
|
|
8576
8667
|
this._nextPasteMode = mode;
|
|
8577
8668
|
}
|
|
@@ -8662,7 +8753,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
8662
8753
|
try {
|
|
8663
8754
|
this._stateChangeManager.flushPendingChanges(unitId);
|
|
8664
8755
|
const result = this._paste(doc, unitId);
|
|
8665
|
-
if (result &&
|
|
8756
|
+
if (result && this.isPasteOptionsEnabled(unitId)) this._savePasteSession(payload, mode === "text" ? cachedSource : source, style, mode, unitId);
|
|
8666
8757
|
return result;
|
|
8667
8758
|
} finally {
|
|
8668
8759
|
this._applyingPaste = false;
|
|
@@ -8886,7 +8977,11 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
8886
8977
|
this._clipboardHooks.push(hook);
|
|
8887
8978
|
return toDisposable(() => {
|
|
8888
8979
|
const index = this._clipboardHooks.indexOf(hook);
|
|
8889
|
-
if (index > -1)
|
|
8980
|
+
if (index > -1) {
|
|
8981
|
+
this._clipboardHooks.splice(index, 1);
|
|
8982
|
+
const state = this._pasteOptions$.value;
|
|
8983
|
+
if (state && !this.isPasteOptionsEnabled(state.unitId)) this.dismissPasteOptions();
|
|
8984
|
+
}
|
|
8890
8985
|
});
|
|
8891
8986
|
}
|
|
8892
8987
|
_applyCopyDocDataHooks(doc, sourceDocuments) {
|
|
@@ -11592,31 +11687,6 @@ const DocCreateTableOperation = {
|
|
|
11592
11687
|
}
|
|
11593
11688
|
};
|
|
11594
11689
|
|
|
11595
|
-
//#endregion
|
|
11596
|
-
//#region src/commands/operations/doc-cursor.operation.ts
|
|
11597
|
-
/**
|
|
11598
|
-
* The operation to move cursor in the current document.
|
|
11599
|
-
*/
|
|
11600
|
-
const MoveCursorOperation = {
|
|
11601
|
-
id: "doc.operation.move-cursor",
|
|
11602
|
-
type: CommandType.OPERATION,
|
|
11603
|
-
handler: (accessor, params) => {
|
|
11604
|
-
if (!params) return false;
|
|
11605
|
-
return true;
|
|
11606
|
-
}
|
|
11607
|
-
};
|
|
11608
|
-
/**
|
|
11609
|
-
* The operation to move selection in the current document.
|
|
11610
|
-
*/
|
|
11611
|
-
const MoveSelectionOperation = {
|
|
11612
|
-
id: "doc.operation.move-selection",
|
|
11613
|
-
type: CommandType.OPERATION,
|
|
11614
|
-
handler: (accessor, params) => {
|
|
11615
|
-
if (!params) return false;
|
|
11616
|
-
return true;
|
|
11617
|
-
}
|
|
11618
|
-
};
|
|
11619
|
-
|
|
11620
11690
|
//#endregion
|
|
11621
11691
|
//#region src/config/config.ts
|
|
11622
11692
|
const DOCS_UI_PLUGIN_CONFIG_KEY = "docs-ui.config";
|
|
@@ -14323,6 +14393,8 @@ function getHeaderFooterTarget(viewModel, editArea, segmentPage, page) {
|
|
|
14323
14393
|
* limitations under the License.
|
|
14324
14394
|
*/
|
|
14325
14395
|
const COMPONENT_DOC_HEADER_FOOTER_PANEL = "COMPONENT_DOC_HEADER_FOOTER_PANEL";
|
|
14396
|
+
const DOC_HEADER_FOOTER_RIBBON_TAB = "docs-ui.ribbon.header-footer";
|
|
14397
|
+
const DOC_HEADER_FOOTER_RIBBON_CONTROL = "DocHeaderFooterRibbonControl";
|
|
14326
14398
|
|
|
14327
14399
|
//#endregion
|
|
14328
14400
|
//#region src/commands/operations/doc-header-footer-panel.operation.ts
|
|
@@ -14380,8 +14452,8 @@ const CoreHeaderFooterCommand = {
|
|
|
14380
14452
|
let resolvedCreateType = createType;
|
|
14381
14453
|
if (headerFooterProps != null) Object.keys(headerFooterProps).forEach((key) => {
|
|
14382
14454
|
const value = headerFooterProps[key];
|
|
14383
|
-
if (resolvedCreateType == null && key === "useFirstPageHeaderFooter" && value === BooleanNumber.TRUE && !headerFooterConfig.firstPageHeaderId) resolvedCreateType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.FIRST_PAGE_HEADER : HeaderFooterType.FIRST_PAGE_FOOTER;
|
|
14384
|
-
else if (resolvedCreateType == null && key === "evenAndOddHeaders" && value === BooleanNumber.TRUE && !headerFooterConfig.evenPageHeaderId) resolvedCreateType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.EVEN_PAGE_HEADER : HeaderFooterType.EVEN_PAGE_FOOTER;
|
|
14455
|
+
if (resolvedCreateType == null && key === "useFirstPageHeaderFooter" && value === BooleanNumber.TRUE && !(editArea === DocumentEditArea.HEADER ? headerFooterConfig.firstPageHeaderId : headerFooterConfig.firstPageFooterId)) resolvedCreateType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.FIRST_PAGE_HEADER : HeaderFooterType.FIRST_PAGE_FOOTER;
|
|
14456
|
+
else if (resolvedCreateType == null && key === "evenAndOddHeaders" && value === BooleanNumber.TRUE && !(editArea === DocumentEditArea.HEADER ? headerFooterConfig.evenPageHeaderId : headerFooterConfig.evenPageFooterId)) resolvedCreateType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.EVEN_PAGE_HEADER : HeaderFooterType.EVEN_PAGE_FOOTER;
|
|
14385
14457
|
});
|
|
14386
14458
|
return commandService.syncExecuteCommand(CreateHeaderFooterCommand.id, {
|
|
14387
14459
|
unitId,
|
|
@@ -14396,8 +14468,8 @@ const CoreHeaderFooterCommand = {
|
|
|
14396
14468
|
const OpenHeaderFooterPanelCommand = {
|
|
14397
14469
|
id: "doc.command.open-header-footer-panel",
|
|
14398
14470
|
type: CommandType.COMMAND,
|
|
14399
|
-
handler: async (accessor,
|
|
14400
|
-
var _skeleton$getSkeleton;
|
|
14471
|
+
handler: async (accessor, params) => {
|
|
14472
|
+
var _skeleton$getSkeleton, _docDataModel$getSelf;
|
|
14401
14473
|
const commandService = accessor.get(ICommandService);
|
|
14402
14474
|
const instanceService = accessor.get(IUniverInstanceService);
|
|
14403
14475
|
const renderManagerService = accessor.get(IRenderManagerService);
|
|
@@ -14414,8 +14486,9 @@ const OpenHeaderFooterPanelCommand = {
|
|
|
14414
14486
|
const currentPage = selectionRenderService.getSegmentPage();
|
|
14415
14487
|
const pageNumber = currentPage >= 0 && currentPage < pages.length ? currentPage : 0;
|
|
14416
14488
|
const page = pages[pageNumber];
|
|
14417
|
-
|
|
14418
|
-
|
|
14489
|
+
const editArea = (params === null || params === void 0 ? void 0 : params.editArea) ?? DocumentEditArea.HEADER;
|
|
14490
|
+
viewModel.setEditArea(editArea);
|
|
14491
|
+
const { createType, headerFooterId, sectionId } = getHeaderFooterTarget(viewModel, editArea, pageNumber, page);
|
|
14419
14492
|
selectionRenderService.setSegmentPage(pageNumber);
|
|
14420
14493
|
if (createType != null) {
|
|
14421
14494
|
const segmentId = generateRandomId(6);
|
|
@@ -14432,6 +14505,21 @@ const OpenHeaderFooterPanelCommand = {
|
|
|
14432
14505
|
return false;
|
|
14433
14506
|
}
|
|
14434
14507
|
} else if (headerFooterId != null) selectionRenderService.setSegment(headerFooterId);
|
|
14508
|
+
const segmentId = selectionRenderService.getSegment();
|
|
14509
|
+
const segmentSnapshot = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getSnapshot();
|
|
14510
|
+
if (!segmentSnapshot) return false;
|
|
14511
|
+
const offset = findFirstCursorOffset(segmentSnapshot);
|
|
14512
|
+
accessor.get(DocSelectionManagerService).replaceDocRanges([{
|
|
14513
|
+
startOffset: offset,
|
|
14514
|
+
endOffset: offset,
|
|
14515
|
+
collapsed: true,
|
|
14516
|
+
segmentId,
|
|
14517
|
+
segmentPage: pageNumber
|
|
14518
|
+
}], {
|
|
14519
|
+
unitId,
|
|
14520
|
+
subUnitId: unitId
|
|
14521
|
+
});
|
|
14522
|
+
selectionRenderService.focus();
|
|
14435
14523
|
return commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "open" });
|
|
14436
14524
|
}
|
|
14437
14525
|
};
|
|
@@ -14474,7 +14562,254 @@ const CloseHeaderFooterCommand = {
|
|
|
14474
14562
|
endOffset: offset
|
|
14475
14563
|
}]);
|
|
14476
14564
|
});
|
|
14477
|
-
commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" });
|
|
14565
|
+
await commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" });
|
|
14566
|
+
return true;
|
|
14567
|
+
}
|
|
14568
|
+
};
|
|
14569
|
+
|
|
14570
|
+
//#endregion
|
|
14571
|
+
//#region src/utils/date-time-field.ts
|
|
14572
|
+
function createDateTimeField(format, locale, date) {
|
|
14573
|
+
const options = format === "time" ? {
|
|
14574
|
+
hour: "2-digit",
|
|
14575
|
+
minute: "2-digit",
|
|
14576
|
+
second: "2-digit",
|
|
14577
|
+
hourCycle: "h23"
|
|
14578
|
+
} : {
|
|
14579
|
+
year: "numeric",
|
|
14580
|
+
month: format === "long" ? "long" : "2-digit",
|
|
14581
|
+
day: "2-digit"
|
|
14582
|
+
};
|
|
14583
|
+
const formatter = new Intl.DateTimeFormat(locale, {
|
|
14584
|
+
...options,
|
|
14585
|
+
calendar: "gregory",
|
|
14586
|
+
numberingSystem: "latn"
|
|
14587
|
+
});
|
|
14588
|
+
const parts = formatter.formatToParts(date);
|
|
14589
|
+
const tokens = {
|
|
14590
|
+
year: "yyyy",
|
|
14591
|
+
month: format === "long" ? "MMMM" : "MM",
|
|
14592
|
+
day: "dd",
|
|
14593
|
+
hour: "HH",
|
|
14594
|
+
minute: "mm",
|
|
14595
|
+
second: "ss"
|
|
14596
|
+
};
|
|
14597
|
+
const mask = parts.map((part) => tokens[part.type] ?? `'${part.value.replace(/'/g, "''")}'`).join("");
|
|
14598
|
+
const fieldType = format === "time" ? "TIME" : "DATE";
|
|
14599
|
+
return {
|
|
14600
|
+
fieldType,
|
|
14601
|
+
instruction: `${fieldType} \\@ "${mask}"`,
|
|
14602
|
+
cachedResult: formatter.format(date)
|
|
14603
|
+
};
|
|
14604
|
+
}
|
|
14605
|
+
function resolveDateTimeField(instruction, locale, date) {
|
|
14606
|
+
try {
|
|
14607
|
+
Intl.getCanonicalLocales(locale);
|
|
14608
|
+
} catch {
|
|
14609
|
+
return;
|
|
14610
|
+
}
|
|
14611
|
+
for (const format of [
|
|
14612
|
+
"short",
|
|
14613
|
+
"long",
|
|
14614
|
+
"time"
|
|
14615
|
+
]) {
|
|
14616
|
+
const field = createDateTimeField(format, locale, date);
|
|
14617
|
+
if (field.instruction === instruction) return field.cachedResult;
|
|
14618
|
+
}
|
|
14619
|
+
}
|
|
14620
|
+
|
|
14621
|
+
//#endregion
|
|
14622
|
+
//#region src/commands/commands/insert-header-footer-field.command.ts
|
|
14623
|
+
const InsertHeaderFooterFieldCommand = {
|
|
14624
|
+
id: "doc.command.insert-header-footer-field",
|
|
14625
|
+
type: CommandType.COMMAND,
|
|
14626
|
+
handler(accessor, params) {
|
|
14627
|
+
var _snapshot$headers, _snapshot$footers, _model$getSelfOrHeade, _body$customRanges;
|
|
14628
|
+
if (!params || ![
|
|
14629
|
+
"PAGE",
|
|
14630
|
+
"NUMPAGES",
|
|
14631
|
+
"DATE",
|
|
14632
|
+
"TIME"
|
|
14633
|
+
].includes(params.fieldType)) return false;
|
|
14634
|
+
const model = accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_DOC);
|
|
14635
|
+
const active = accessor.get(DocSelectionManagerService).getActiveTextRange();
|
|
14636
|
+
const selection = params.selection ?? active;
|
|
14637
|
+
const segmentId = params.segmentId ?? (active === null || active === void 0 ? void 0 : active.segmentId);
|
|
14638
|
+
const snapshot = model === null || model === void 0 ? void 0 : model.getSnapshot();
|
|
14639
|
+
if (!model || (snapshot === null || snapshot === void 0 ? void 0 : snapshot.disabled) || !selection || !segmentId || !(snapshot === null || snapshot === void 0 || (_snapshot$headers = snapshot.headers) === null || _snapshot$headers === void 0 ? void 0 : _snapshot$headers[segmentId]) && !(snapshot === null || snapshot === void 0 || (_snapshot$footers = snapshot.footers) === null || _snapshot$footers === void 0 ? void 0 : _snapshot$footers[segmentId])) return false;
|
|
14640
|
+
const body = (_model$getSelfOrHeade = model.getSelfOrHeaderFooterModel(segmentId)) === null || _model$getSelfOrHeade === void 0 ? void 0 : _model$getSelfOrHeade.getBody();
|
|
14641
|
+
if (!body || params.expectedDataStream != null && params.expectedDataStream !== body.dataStream || !Number.isInteger(selection.startOffset) || !Number.isInteger(selection.endOffset) || selection.startOffset < 0 || selection.endOffset < selection.startOffset || selection.endOffset > body.dataStream.length - 2) return false;
|
|
14642
|
+
if (!canEditDocumentTargets(accessor.get(IPermissionService), params.unitId, getDocumentEditTargetObjectIds(model, segmentId, selection))) return false;
|
|
14643
|
+
if ((_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.some((range) => {
|
|
14644
|
+
var _range$properties;
|
|
14645
|
+
return range.rangeType === CustomRangeType.FIELD && ((_range$properties = range.properties) === null || _range$properties === void 0 ? void 0 : _range$properties.locked) === BooleanNumber.TRUE && selection.startOffset <= range.endIndex && selection.endOffset > range.startIndex;
|
|
14646
|
+
})) return false;
|
|
14647
|
+
const locale = LOCALE_META[accessor.get(LocaleService).getCurrentLocale()].tag;
|
|
14648
|
+
let properties;
|
|
14649
|
+
if (params.fieldType === "DATE" || params.fieldType === "TIME") {
|
|
14650
|
+
const format = params.format ?? (params.fieldType === "TIME" ? "time" : "short");
|
|
14651
|
+
if (![
|
|
14652
|
+
"short",
|
|
14653
|
+
"long",
|
|
14654
|
+
"time"
|
|
14655
|
+
].includes(format)) return false;
|
|
14656
|
+
properties = createDateTimeField(format, locale, /* @__PURE__ */ new Date());
|
|
14657
|
+
} else {
|
|
14658
|
+
var _accessor$get$getRend, _skeleton$getSkeleton;
|
|
14659
|
+
const skeleton = (_accessor$get$getRend = accessor.get(IRenderManagerService).getRenderUnitById(params.unitId)) === null || _accessor$get$getRend === void 0 ? void 0 : _accessor$get$getRend.with(DocSkeletonManagerService).getSkeleton();
|
|
14660
|
+
const pages = skeleton === null || skeleton === void 0 || (_skeleton$getSkeleton = skeleton.getSkeletonData()) === null || _skeleton$getSkeleton === void 0 ? void 0 : _skeleton$getSkeleton.pages;
|
|
14661
|
+
if (!(pages === null || pages === void 0 ? void 0 : pages.length)) return false;
|
|
14662
|
+
const pageIndex = params.segmentPage ?? (active === null || active === void 0 ? void 0 : active.segmentPage) ?? 0;
|
|
14663
|
+
const page = pages[Math.max(0, pageIndex)];
|
|
14664
|
+
if (!page) return false;
|
|
14665
|
+
properties = {
|
|
14666
|
+
fieldType: params.fieldType,
|
|
14667
|
+
instruction: params.fieldType,
|
|
14668
|
+
cachedResult: String(params.fieldType === "PAGE" ? page.pageNumber : (skeleton === null || skeleton === void 0 ? void 0 : skeleton.getCompletedPageCount()) ?? "…")
|
|
14669
|
+
};
|
|
14670
|
+
}
|
|
14671
|
+
const automatic = params.automatic !== false || params.fieldType === "PAGE" || params.fieldType === "NUMPAGES";
|
|
14672
|
+
const dataStream = automatic ? `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${properties.cachedResult}${DataStreamTreeTokenType.CUSTOM_RANGE_END}` : properties.cachedResult;
|
|
14673
|
+
const style = accessor.get(DocMenuStyleService);
|
|
14674
|
+
const textRun = getTextRunForSelection(body, selection, style.getDefaultStyle(), style.getStyleCache(), false);
|
|
14675
|
+
return accessor.get(ICommandService).syncExecuteCommand(InsertTextCommand.id, {
|
|
14676
|
+
unitId: params.unitId,
|
|
14677
|
+
segmentId,
|
|
14678
|
+
range: selection,
|
|
14679
|
+
debounce: false,
|
|
14680
|
+
body: {
|
|
14681
|
+
dataStream,
|
|
14682
|
+
textRuns: [{
|
|
14683
|
+
...textRun,
|
|
14684
|
+
ts: {
|
|
14685
|
+
...textRun.ts,
|
|
14686
|
+
lang: locale
|
|
14687
|
+
},
|
|
14688
|
+
st: 0,
|
|
14689
|
+
ed: dataStream.length
|
|
14690
|
+
}],
|
|
14691
|
+
customRanges: automatic ? [{
|
|
14692
|
+
startIndex: 0,
|
|
14693
|
+
endIndex: dataStream.length - 1,
|
|
14694
|
+
rangeId: generateRandomId(),
|
|
14695
|
+
rangeType: CustomRangeType.FIELD,
|
|
14696
|
+
wholeEntity: false,
|
|
14697
|
+
properties: {
|
|
14698
|
+
...properties,
|
|
14699
|
+
sourceKind: "complex"
|
|
14700
|
+
}
|
|
14701
|
+
}] : []
|
|
14702
|
+
},
|
|
14703
|
+
textRanges: [{
|
|
14704
|
+
...selection,
|
|
14705
|
+
segmentId,
|
|
14706
|
+
segmentPage: params.segmentPage ?? (active === null || active === void 0 ? void 0 : active.segmentPage),
|
|
14707
|
+
startOffset: selection.startOffset + dataStream.length,
|
|
14708
|
+
endOffset: selection.startOffset + dataStream.length,
|
|
14709
|
+
collapsed: true
|
|
14710
|
+
}]
|
|
14711
|
+
});
|
|
14712
|
+
}
|
|
14713
|
+
};
|
|
14714
|
+
|
|
14715
|
+
//#endregion
|
|
14716
|
+
//#region src/commands/commands/refresh-header-footer-fields.command.ts
|
|
14717
|
+
const RefreshHeaderFooterFieldsCommand = {
|
|
14718
|
+
id: "doc.command.refresh-header-footer-fields",
|
|
14719
|
+
type: CommandType.COMMAND,
|
|
14720
|
+
handler(accessor, params) {
|
|
14721
|
+
if (!params) return false;
|
|
14722
|
+
const model = accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_DOC);
|
|
14723
|
+
const snapshot = model === null || model === void 0 ? void 0 : model.getSnapshot();
|
|
14724
|
+
if (!model || !snapshot || snapshot.disabled) return false;
|
|
14725
|
+
const permissions = accessor.get(IPermissionService);
|
|
14726
|
+
const locale = LOCALE_META[accessor.get(LocaleService).getCurrentLocale()].tag;
|
|
14727
|
+
const now = /* @__PURE__ */ new Date();
|
|
14728
|
+
const selections = accessor.get(DocSelectionManagerService).getTextRanges({
|
|
14729
|
+
unitId: params.unitId,
|
|
14730
|
+
subUnitId: params.unitId
|
|
14731
|
+
}) ?? [];
|
|
14732
|
+
let actions = null;
|
|
14733
|
+
for (const [segmentId, segment] of Object.entries({
|
|
14734
|
+
"": { body: snapshot.body },
|
|
14735
|
+
...snapshot.headers,
|
|
14736
|
+
...snapshot.footers
|
|
14737
|
+
})) {
|
|
14738
|
+
if (!segment.body) continue;
|
|
14739
|
+
const textX = refreshDateTimeFields(segment.body, locale, now, (field) => (!params.selectionOnly || selections.some((selection) => (selection.segmentId ?? "") === segmentId && selection.startOffset <= field.endIndex && selection.endOffset > field.startIndex)) && canEditDocumentTargets(permissions, params.unitId, getDocumentEditTargetObjectIds(model, segmentId, {
|
|
14740
|
+
startOffset: field.startIndex,
|
|
14741
|
+
endOffset: field.endIndex + 1
|
|
14742
|
+
})));
|
|
14743
|
+
if (textX.length) actions = JSONX.compose(actions, JSONX.getInstance().editOp(textX, getRichTextEditPath(model, segmentId)));
|
|
14744
|
+
}
|
|
14745
|
+
if (JSONX.isNoop(actions)) return true;
|
|
14746
|
+
if (!params.onOpen) accessor.get(DocStateChangeManagerService).flushPendingChanges(params.unitId);
|
|
14747
|
+
return Boolean(accessor.get(ICommandService).syncExecuteCommand(RichTextEditingMutation.id, {
|
|
14748
|
+
unitId: params.unitId,
|
|
14749
|
+
actions,
|
|
14750
|
+
textRanges: transformDocumentTextRanges(actions, [...selections]),
|
|
14751
|
+
noHistory: params.onOpen === true,
|
|
14752
|
+
debounce: false,
|
|
14753
|
+
trigger: RefreshHeaderFooterFieldsCommand.id
|
|
14754
|
+
}));
|
|
14755
|
+
}
|
|
14756
|
+
};
|
|
14757
|
+
const UpdateSelectedDocFieldsCommand = {
|
|
14758
|
+
id: "doc.command.update-selected-fields",
|
|
14759
|
+
type: CommandType.COMMAND,
|
|
14760
|
+
handler(accessor) {
|
|
14761
|
+
const model = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
14762
|
+
if (!model) return false;
|
|
14763
|
+
return accessor.get(ICommandService).syncExecuteCommand(RefreshHeaderFooterFieldsCommand.id, {
|
|
14764
|
+
unitId: model.getUnitId(),
|
|
14765
|
+
selectionOnly: true
|
|
14766
|
+
});
|
|
14767
|
+
}
|
|
14768
|
+
};
|
|
14769
|
+
function refreshDateTimeFields(body, locale, date, canEdit) {
|
|
14770
|
+
const textX = new TextX();
|
|
14771
|
+
let cursor = 0;
|
|
14772
|
+
const ranges = [...body.customRanges ?? []].sort((a, b) => a.startIndex - b.startIndex);
|
|
14773
|
+
for (const field of ranges) {
|
|
14774
|
+
var _body$textRuns, _run$ts;
|
|
14775
|
+
const properties = field.properties;
|
|
14776
|
+
if (field.rangeType !== CustomRangeType.FIELD || (properties === null || properties === void 0 ? void 0 : properties.locked) === BooleanNumber.TRUE || (properties === null || properties === void 0 ? void 0 : properties.fieldType) !== "DATE" && (properties === null || properties === void 0 ? void 0 : properties.fieldType) !== "TIME" || !canEdit(field) || ranges.some((range) => range !== field && range.startIndex > field.startIndex && range.endIndex < field.endIndex)) continue;
|
|
14777
|
+
const start = field.startIndex;
|
|
14778
|
+
const run = (_body$textRuns = body.textRuns) === null || _body$textRuns === void 0 ? void 0 : _body$textRuns.find((run) => run.st <= start + 1 && run.ed > start + 1);
|
|
14779
|
+
const value = resolveDateTimeField(properties.instruction, (run === null || run === void 0 || (_run$ts = run.ts) === null || _run$ts === void 0 ? void 0 : _run$ts.lang) ?? locale, date);
|
|
14780
|
+
if (value == null || start < cursor || body.dataStream.slice(start + 1, field.endIndex) === value && properties.cachedResult === value) continue;
|
|
14781
|
+
const dataStream = `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${value}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`;
|
|
14782
|
+
textX.retain(start - cursor).delete(field.endIndex - start + 1).insert(dataStream.length, {
|
|
14783
|
+
dataStream,
|
|
14784
|
+
textRuns: run ? [{
|
|
14785
|
+
...run,
|
|
14786
|
+
st: 0,
|
|
14787
|
+
ed: dataStream.length
|
|
14788
|
+
}] : [],
|
|
14789
|
+
customRanges: [{
|
|
14790
|
+
...field,
|
|
14791
|
+
startIndex: 0,
|
|
14792
|
+
endIndex: dataStream.length - 1,
|
|
14793
|
+
properties: {
|
|
14794
|
+
...properties,
|
|
14795
|
+
cachedResult: value
|
|
14796
|
+
}
|
|
14797
|
+
}]
|
|
14798
|
+
});
|
|
14799
|
+
cursor = field.endIndex + 1;
|
|
14800
|
+
}
|
|
14801
|
+
return textX.serialize();
|
|
14802
|
+
}
|
|
14803
|
+
|
|
14804
|
+
//#endregion
|
|
14805
|
+
//#region src/commands/operations/doc-header-footer-ribbon.operation.ts
|
|
14806
|
+
const DocHeaderFooterRibbonOperation = {
|
|
14807
|
+
id: SidebarDocHeaderFooterPanelOperation.id,
|
|
14808
|
+
type: SidebarDocHeaderFooterPanelOperation.type,
|
|
14809
|
+
handler(accessor, params) {
|
|
14810
|
+
const ribbon = accessor.get(IRibbonService);
|
|
14811
|
+
if ((params === null || params === void 0 ? void 0 : params.value) === "open") ribbon.showContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB, { activate: true });
|
|
14812
|
+
else ribbon.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
|
|
14478
14813
|
return true;
|
|
14479
14814
|
}
|
|
14480
14815
|
};
|
|
@@ -15103,8 +15438,12 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
|
|
|
15103
15438
|
}
|
|
15104
15439
|
_initPointer() {
|
|
15105
15440
|
let preCursor = CURSOR_TYPE.TEXT;
|
|
15441
|
+
let pointing = false;
|
|
15106
15442
|
this.disposeWithMe(this.hoverCustomRanges$.subscribe((ranges) => {
|
|
15107
|
-
|
|
15443
|
+
const nextPointing = ranges.some(({ range }) => range.rangeType !== CustomRangeType.FIELD);
|
|
15444
|
+
if (nextPointing === pointing) return;
|
|
15445
|
+
pointing = nextPointing;
|
|
15446
|
+
if (pointing) {
|
|
15108
15447
|
preCursor = this._context.scene.getCursor();
|
|
15109
15448
|
this._context.scene.setCursor(CURSOR_TYPE.POINTER);
|
|
15110
15449
|
} else this._context.scene.setCursor(preCursor);
|
|
@@ -15227,6 +15566,10 @@ let DocEventManagerService = class DocEventManagerService extends Disposable {
|
|
|
15227
15566
|
this._buildBulletBounds();
|
|
15228
15567
|
return [...this._bulletBounds];
|
|
15229
15568
|
}
|
|
15569
|
+
getCustomRangeBounds() {
|
|
15570
|
+
this._buildCustomRangeBounds();
|
|
15571
|
+
return [...this._customRangeBounds];
|
|
15572
|
+
}
|
|
15230
15573
|
getListContextMenuBulletByOffset(offsetX, offsetY) {
|
|
15231
15574
|
const point = transformOffset2Bound(offsetX, offsetY, this._context.scene);
|
|
15232
15575
|
return this._calcActiveBullet(point) ?? this._calcActiveListParagraph(point);
|
|
@@ -15772,132 +16115,50 @@ const OpenDocPermissionPanelOperation = {
|
|
|
15772
16115
|
};
|
|
15773
16116
|
|
|
15774
16117
|
//#endregion
|
|
15775
|
-
//#region src/
|
|
15776
|
-
|
|
15777
|
-
|
|
15778
|
-
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
|
|
15785
|
-
|
|
15786
|
-
|
|
15787
|
-
|
|
15788
|
-
|
|
15789
|
-
|
|
15790
|
-
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15794
|
-
|
|
15795
|
-
|
|
15796
|
-
|
|
15797
|
-
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
|
|
15802
|
-
|
|
15803
|
-
|
|
15804
|
-
|
|
15805
|
-
|
|
15806
|
-
|
|
15807
|
-
|
|
15808
|
-
|
|
15809
|
-
|
|
15810
|
-
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
15814
|
-
|
|
15815
|
-
|
|
15816
|
-
|
|
15817
|
-
|
|
15818
|
-
|
|
15819
|
-
handler: (accessor) => {
|
|
15820
|
-
accessor.get(DocParagraphSettingController).openPanel();
|
|
15821
|
-
return true;
|
|
15822
|
-
}
|
|
15823
|
-
};
|
|
15824
|
-
|
|
15825
|
-
//#endregion
|
|
15826
|
-
//#region src/views/section-setting/component-name.ts
|
|
15827
|
-
/**
|
|
15828
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
15829
|
-
*
|
|
15830
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15831
|
-
* you may not use this file except in compliance with the License.
|
|
15832
|
-
* You may obtain a copy of the License at
|
|
15833
|
-
*
|
|
15834
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15835
|
-
*
|
|
15836
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15837
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15838
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15839
|
-
* See the License for the specific language governing permissions and
|
|
15840
|
-
* limitations under the License.
|
|
15841
|
-
*/
|
|
15842
|
-
const DOC_SECTION_SETTING_COMPONENT = "doc_ui_section-setting-panel";
|
|
15843
|
-
|
|
15844
|
-
//#endregion
|
|
15845
|
-
//#region src/controllers/doc-section-setting.controller.ts
|
|
15846
|
-
/**
|
|
15847
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
15848
|
-
*
|
|
15849
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15850
|
-
* you may not use this file except in compliance with the License.
|
|
15851
|
-
* You may obtain a copy of the License at
|
|
15852
|
-
*
|
|
15853
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15854
|
-
*
|
|
15855
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15856
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15857
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15858
|
-
* See the License for the specific language governing permissions and
|
|
15859
|
-
* limitations under the License.
|
|
15860
|
-
*/
|
|
15861
|
-
let DocSectionSettingController = class DocSectionSettingController extends Disposable {
|
|
15862
|
-
constructor(_sidebarService, _selectionManager) {
|
|
15863
|
-
super();
|
|
15864
|
-
this._sidebarService = _sidebarService;
|
|
15865
|
-
this._selectionManager = _selectionManager;
|
|
15866
|
-
_defineProperty(this, "_panelId", "DocSectionSetting");
|
|
15867
|
-
}
|
|
15868
|
-
openPanel() {
|
|
15869
|
-
this._sidebarService.open({
|
|
15870
|
-
header: { title: "docs-ui.doc.slider.sectionSetting" },
|
|
15871
|
-
id: this._panelId,
|
|
15872
|
-
children: { label: DOC_SECTION_SETTING_COMPONENT },
|
|
15873
|
-
width: 300
|
|
15874
|
-
});
|
|
15875
|
-
}
|
|
15876
|
-
closePanel() {
|
|
15877
|
-
this._sidebarService.close(this._panelId);
|
|
15878
|
-
}
|
|
15879
|
-
navigateToSectionEnd(unitId, sectionStart, sectionEnd) {
|
|
15880
|
-
const params = {
|
|
15881
|
-
unitId,
|
|
15882
|
-
subUnitId: unitId
|
|
15883
|
-
};
|
|
15884
|
-
const cursorOffset = Math.max(sectionStart, sectionEnd - 1);
|
|
15885
|
-
this._selectionManager.replaceDocRanges([{
|
|
15886
|
-
startOffset: cursorOffset,
|
|
15887
|
-
endOffset: cursorOffset
|
|
15888
|
-
}], params, true, { shouldFocus: false });
|
|
15889
|
-
}
|
|
15890
|
-
};
|
|
15891
|
-
DocSectionSettingController = __decorate([__decorateParam(0, Inject(ISidebarService)), __decorateParam(1, Inject(DocSelectionManagerService))], DocSectionSettingController);
|
|
15892
|
-
|
|
15893
|
-
//#endregion
|
|
15894
|
-
//#region src/commands/operations/doc-section-setting-panel.operation.ts
|
|
15895
|
-
const DocSectionSettingPanelOperation = {
|
|
15896
|
-
id: "sidebar.operation.doc-section-setting-panel",
|
|
15897
|
-
type: CommandType.OPERATION,
|
|
15898
|
-
handler: (accessor) => {
|
|
15899
|
-
accessor.get(DocSectionSettingController).openPanel();
|
|
15900
|
-
return true;
|
|
16118
|
+
//#region src/commands/commands/insert-special-character.command.ts
|
|
16119
|
+
const InsertSpecialCharacterCommand = {
|
|
16120
|
+
id: "doc.command.insert-special-character",
|
|
16121
|
+
type: CommandType.COMMAND,
|
|
16122
|
+
handler: (accessor, params) => {
|
|
16123
|
+
var _docDataModel$getSelf, _getEditorRuntimeConf;
|
|
16124
|
+
if (!(params === null || params === void 0 ? void 0 : params.value)) return false;
|
|
16125
|
+
const commandService = accessor.get(ICommandService);
|
|
16126
|
+
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
16127
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
16128
|
+
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
16129
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
16130
|
+
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
16131
|
+
if (!docDataModel || !activeRange) return false;
|
|
16132
|
+
const { segmentId } = activeRange;
|
|
16133
|
+
const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
16134
|
+
if (!originBody) return false;
|
|
16135
|
+
const { value } = params;
|
|
16136
|
+
const curTextRun = getTextRunForSelection(originBody, activeRange, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache(), false, ((_getEditorRuntimeConf = getEditorRuntimeConfig(docDataModel)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.inheritParagraphStartStyle) === true);
|
|
16137
|
+
const curCustomRange = getCustomRangeAtPosition(originBody.customRanges ?? [], activeRange.endOffset);
|
|
16138
|
+
const curCustomDecorations = getCustomDecorationAtPosition(originBody.customDecorations ?? [], activeRange.endOffset);
|
|
16139
|
+
return commandService.executeCommand(InsertTextCommand.id, {
|
|
16140
|
+
unitId: docDataModel.getUnitId(),
|
|
16141
|
+
body: {
|
|
16142
|
+
dataStream: value,
|
|
16143
|
+
textRuns: [{
|
|
16144
|
+
...curTextRun,
|
|
16145
|
+
st: 0,
|
|
16146
|
+
ed: value.length
|
|
16147
|
+
}],
|
|
16148
|
+
customRanges: curCustomRange ? [{
|
|
16149
|
+
...curCustomRange,
|
|
16150
|
+
startIndex: 0,
|
|
16151
|
+
endIndex: value.length - 1
|
|
16152
|
+
}] : [],
|
|
16153
|
+
customDecorations: curCustomDecorations.map((customDecoration) => ({
|
|
16154
|
+
...customDecoration,
|
|
16155
|
+
startIndex: 0,
|
|
16156
|
+
endIndex: value.length - 1
|
|
16157
|
+
}))
|
|
16158
|
+
},
|
|
16159
|
+
range: activeRange,
|
|
16160
|
+
segmentId
|
|
16161
|
+
});
|
|
15901
16162
|
}
|
|
15902
16163
|
};
|
|
15903
16164
|
|
|
@@ -16331,54 +16592,6 @@ const DocOpenPageSettingCommand = {
|
|
|
16331
16592
|
}
|
|
16332
16593
|
};
|
|
16333
16594
|
|
|
16334
|
-
//#endregion
|
|
16335
|
-
//#region src/commands/commands/insert-special-character.command.ts
|
|
16336
|
-
const InsertSpecialCharacterCommand = {
|
|
16337
|
-
id: "doc.command.insert-special-character",
|
|
16338
|
-
type: CommandType.COMMAND,
|
|
16339
|
-
handler: (accessor, params) => {
|
|
16340
|
-
var _docDataModel$getSelf, _getEditorRuntimeConf;
|
|
16341
|
-
if (!(params === null || params === void 0 ? void 0 : params.value)) return false;
|
|
16342
|
-
const commandService = accessor.get(ICommandService);
|
|
16343
|
-
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
16344
|
-
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
16345
|
-
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
16346
|
-
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
16347
|
-
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
16348
|
-
if (!docDataModel || !activeRange) return false;
|
|
16349
|
-
const { segmentId } = activeRange;
|
|
16350
|
-
const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
16351
|
-
if (!originBody) return false;
|
|
16352
|
-
const { value } = params;
|
|
16353
|
-
const curTextRun = getTextRunForSelection(originBody, activeRange, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache(), false, ((_getEditorRuntimeConf = getEditorRuntimeConfig(docDataModel)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.inheritParagraphStartStyle) === true);
|
|
16354
|
-
const curCustomRange = getCustomRangeAtPosition(originBody.customRanges ?? [], activeRange.endOffset);
|
|
16355
|
-
const curCustomDecorations = getCustomDecorationAtPosition(originBody.customDecorations ?? [], activeRange.endOffset);
|
|
16356
|
-
return commandService.executeCommand(InsertTextCommand.id, {
|
|
16357
|
-
unitId: docDataModel.getUnitId(),
|
|
16358
|
-
body: {
|
|
16359
|
-
dataStream: value,
|
|
16360
|
-
textRuns: [{
|
|
16361
|
-
...curTextRun,
|
|
16362
|
-
st: 0,
|
|
16363
|
-
ed: value.length
|
|
16364
|
-
}],
|
|
16365
|
-
customRanges: curCustomRange ? [{
|
|
16366
|
-
...curCustomRange,
|
|
16367
|
-
startIndex: 0,
|
|
16368
|
-
endIndex: value.length - 1
|
|
16369
|
-
}] : [],
|
|
16370
|
-
customDecorations: curCustomDecorations.map((customDecoration) => ({
|
|
16371
|
-
...customDecoration,
|
|
16372
|
-
startIndex: 0,
|
|
16373
|
-
endIndex: value.length - 1
|
|
16374
|
-
}))
|
|
16375
|
-
},
|
|
16376
|
-
range: activeRange,
|
|
16377
|
-
segmentId
|
|
16378
|
-
});
|
|
16379
|
-
}
|
|
16380
|
-
};
|
|
16381
|
-
|
|
16382
16595
|
//#endregion
|
|
16383
16596
|
//#region src/views/const.ts
|
|
16384
16597
|
/**
|
|
@@ -17735,6 +17948,210 @@ function PageSettingMenuItemFactory(accessor) {
|
|
|
17735
17948
|
};
|
|
17736
17949
|
}
|
|
17737
17950
|
|
|
17951
|
+
//#endregion
|
|
17952
|
+
//#region src/menu/header-footer-ribbon.ts
|
|
17953
|
+
const headerFooterRibbonSchema = {
|
|
17954
|
+
[ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.FORMAT]: { [UpdateSelectedDocFieldsCommand.id]: {
|
|
17955
|
+
order: 1,
|
|
17956
|
+
menuItemFactory: (accessor) => {
|
|
17957
|
+
const instances = accessor.get(IUniverInstanceService);
|
|
17958
|
+
const selections = accessor.get(DocSelectionManagerService);
|
|
17959
|
+
return {
|
|
17960
|
+
id: UpdateSelectedDocFieldsCommand.id,
|
|
17961
|
+
type: MenuItemType.BUTTON,
|
|
17962
|
+
title: "docs-ui.headerFooter.refreshFields",
|
|
17963
|
+
disabled$: disableMenuWithoutDocumentUnitPermission(accessor, UnitAction.Edit),
|
|
17964
|
+
hidden$: combineLatest([instances.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), selections.textSelection$.pipe(startWith(null))]).pipe(map(([model]) => !model || !(selections.getTextRanges({
|
|
17965
|
+
unitId: model.getUnitId(),
|
|
17966
|
+
subUnitId: model.getUnitId()
|
|
17967
|
+
}) ?? []).some((selection) => {
|
|
17968
|
+
var _model$getSelfOrHeade;
|
|
17969
|
+
return (_model$getSelfOrHeade = model.getSelfOrHeaderFooterModel(selection.segmentId)) === null || _model$getSelfOrHeade === void 0 || (_model$getSelfOrHeade = _model$getSelfOrHeade.getBody()) === null || _model$getSelfOrHeade === void 0 || (_model$getSelfOrHeade = _model$getSelfOrHeade.customRanges) === null || _model$getSelfOrHeade === void 0 ? void 0 : _model$getSelfOrHeade.some((field) => field.rangeType === CustomRangeType.FIELD && selection.startOffset <= field.endIndex && selection.endOffset > field.startIndex);
|
|
17970
|
+
})))
|
|
17971
|
+
};
|
|
17972
|
+
}
|
|
17973
|
+
} } },
|
|
17974
|
+
[MenuManagerPosition.RIBBON]: { [DOC_HEADER_FOOTER_RIBBON_TAB]: {
|
|
17975
|
+
order: 90,
|
|
17976
|
+
title: "docs-ui.toolbar.headerFooter",
|
|
17977
|
+
contextual: true,
|
|
17978
|
+
...Object.fromEntries([
|
|
17979
|
+
"insertion",
|
|
17980
|
+
"navigation",
|
|
17981
|
+
"options",
|
|
17982
|
+
"position"
|
|
17983
|
+
].map((kind, order) => [`${DOC_HEADER_FOOTER_RIBBON_TAB}.${kind}`, {
|
|
17984
|
+
order,
|
|
17985
|
+
[`${DOC_HEADER_FOOTER_RIBBON_CONTROL}.${kind}`]: {
|
|
17986
|
+
order: 0,
|
|
17987
|
+
gridLayout: {
|
|
17988
|
+
row: 1,
|
|
17989
|
+
column: 1,
|
|
17990
|
+
rowSpan: 2
|
|
17991
|
+
},
|
|
17992
|
+
menuItemFactory: () => ({
|
|
17993
|
+
id: `${DOC_HEADER_FOOTER_RIBBON_CONTROL}.${kind}`,
|
|
17994
|
+
type: MenuItemType.BUTTON,
|
|
17995
|
+
label: {
|
|
17996
|
+
name: DOC_HEADER_FOOTER_RIBBON_CONTROL,
|
|
17997
|
+
hoverable: false,
|
|
17998
|
+
props: { kind }
|
|
17999
|
+
}
|
|
18000
|
+
})
|
|
18001
|
+
}
|
|
18002
|
+
}])),
|
|
18003
|
+
"docs-ui.headerFooter.close": {
|
|
18004
|
+
order: 5,
|
|
18005
|
+
[CloseHeaderFooterCommand.id]: {
|
|
18006
|
+
order: 0,
|
|
18007
|
+
gridLayout: {
|
|
18008
|
+
row: 1,
|
|
18009
|
+
column: 1,
|
|
18010
|
+
rowSpan: 2,
|
|
18011
|
+
showLabel: true
|
|
18012
|
+
},
|
|
18013
|
+
menuItemFactory: () => ({
|
|
18014
|
+
id: CloseHeaderFooterCommand.id,
|
|
18015
|
+
type: MenuItemType.BUTTON,
|
|
18016
|
+
icon: "CloseIcon",
|
|
18017
|
+
title: "docs-ui.headerFooter.closeHeaderFooter",
|
|
18018
|
+
tooltip: "docs-ui.headerFooter.closeHeaderFooter"
|
|
18019
|
+
})
|
|
18020
|
+
}
|
|
18021
|
+
}
|
|
18022
|
+
} }
|
|
18023
|
+
};
|
|
18024
|
+
|
|
18025
|
+
//#endregion
|
|
18026
|
+
//#region src/controllers/doc-paragraph-setting.controller.ts
|
|
18027
|
+
/**
|
|
18028
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
18029
|
+
*
|
|
18030
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18031
|
+
* you may not use this file except in compliance with the License.
|
|
18032
|
+
* You may obtain a copy of the License at
|
|
18033
|
+
*
|
|
18034
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18035
|
+
*
|
|
18036
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18037
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18038
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18039
|
+
* See the License for the specific language governing permissions and
|
|
18040
|
+
* limitations under the License.
|
|
18041
|
+
*/
|
|
18042
|
+
const paragraphSettingIndexKey$1 = "doc_ui_paragraph-setting-panel";
|
|
18043
|
+
let DocParagraphSettingController = class DocParagraphSettingController extends Disposable {
|
|
18044
|
+
constructor(_commandService, _sidebarService) {
|
|
18045
|
+
super();
|
|
18046
|
+
this._commandService = _commandService;
|
|
18047
|
+
this._sidebarService = _sidebarService;
|
|
18048
|
+
_defineProperty(this, "_id", void 0);
|
|
18049
|
+
}
|
|
18050
|
+
openPanel() {
|
|
18051
|
+
const props = {
|
|
18052
|
+
header: { title: "docs-ui.doc.slider.paragraphSetting" },
|
|
18053
|
+
id: this._id,
|
|
18054
|
+
children: { label: paragraphSettingIndexKey$1 },
|
|
18055
|
+
width: 300
|
|
18056
|
+
};
|
|
18057
|
+
this._sidebarService.open(props);
|
|
18058
|
+
}
|
|
18059
|
+
closePanel() {
|
|
18060
|
+
this._sidebarService.close(this._id);
|
|
18061
|
+
}
|
|
18062
|
+
};
|
|
18063
|
+
DocParagraphSettingController = __decorate([__decorateParam(0, ICommandService), __decorateParam(1, Inject(ISidebarService))], DocParagraphSettingController);
|
|
18064
|
+
|
|
18065
|
+
//#endregion
|
|
18066
|
+
//#region src/commands/operations/doc-paragraph-setting-panel.operation.ts
|
|
18067
|
+
const DocParagraphSettingPanelOperation = {
|
|
18068
|
+
id: "sidebar.operation.doc-paragraph-setting-panel",
|
|
18069
|
+
type: CommandType.OPERATION,
|
|
18070
|
+
handler: (accessor) => {
|
|
18071
|
+
accessor.get(DocParagraphSettingController).openPanel();
|
|
18072
|
+
return true;
|
|
18073
|
+
}
|
|
18074
|
+
};
|
|
18075
|
+
|
|
18076
|
+
//#endregion
|
|
18077
|
+
//#region src/views/section-setting/component-name.ts
|
|
18078
|
+
/**
|
|
18079
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
18080
|
+
*
|
|
18081
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18082
|
+
* you may not use this file except in compliance with the License.
|
|
18083
|
+
* You may obtain a copy of the License at
|
|
18084
|
+
*
|
|
18085
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18086
|
+
*
|
|
18087
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18088
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18089
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18090
|
+
* See the License for the specific language governing permissions and
|
|
18091
|
+
* limitations under the License.
|
|
18092
|
+
*/
|
|
18093
|
+
const DOC_SECTION_SETTING_COMPONENT = "doc_ui_section-setting-panel";
|
|
18094
|
+
|
|
18095
|
+
//#endregion
|
|
18096
|
+
//#region src/controllers/doc-section-setting.controller.ts
|
|
18097
|
+
/**
|
|
18098
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
18099
|
+
*
|
|
18100
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18101
|
+
* you may not use this file except in compliance with the License.
|
|
18102
|
+
* You may obtain a copy of the License at
|
|
18103
|
+
*
|
|
18104
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18105
|
+
*
|
|
18106
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18107
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18108
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18109
|
+
* See the License for the specific language governing permissions and
|
|
18110
|
+
* limitations under the License.
|
|
18111
|
+
*/
|
|
18112
|
+
let DocSectionSettingController = class DocSectionSettingController extends Disposable {
|
|
18113
|
+
constructor(_sidebarService, _selectionManager) {
|
|
18114
|
+
super();
|
|
18115
|
+
this._sidebarService = _sidebarService;
|
|
18116
|
+
this._selectionManager = _selectionManager;
|
|
18117
|
+
_defineProperty(this, "_panelId", "DocSectionSetting");
|
|
18118
|
+
}
|
|
18119
|
+
openPanel() {
|
|
18120
|
+
this._sidebarService.open({
|
|
18121
|
+
header: { title: "docs-ui.doc.slider.sectionSetting" },
|
|
18122
|
+
id: this._panelId,
|
|
18123
|
+
children: { label: DOC_SECTION_SETTING_COMPONENT },
|
|
18124
|
+
width: 300
|
|
18125
|
+
});
|
|
18126
|
+
}
|
|
18127
|
+
closePanel() {
|
|
18128
|
+
this._sidebarService.close(this._panelId);
|
|
18129
|
+
}
|
|
18130
|
+
navigateToSectionEnd(unitId, sectionStart, sectionEnd) {
|
|
18131
|
+
const params = {
|
|
18132
|
+
unitId,
|
|
18133
|
+
subUnitId: unitId
|
|
18134
|
+
};
|
|
18135
|
+
const cursorOffset = Math.max(sectionStart, sectionEnd - 1);
|
|
18136
|
+
this._selectionManager.replaceDocRanges([{
|
|
18137
|
+
startOffset: cursorOffset,
|
|
18138
|
+
endOffset: cursorOffset
|
|
18139
|
+
}], params, true, { shouldFocus: false });
|
|
18140
|
+
}
|
|
18141
|
+
};
|
|
18142
|
+
DocSectionSettingController = __decorate([__decorateParam(0, Inject(ISidebarService)), __decorateParam(1, Inject(DocSelectionManagerService))], DocSectionSettingController);
|
|
18143
|
+
|
|
18144
|
+
//#endregion
|
|
18145
|
+
//#region src/commands/operations/doc-section-setting-panel.operation.ts
|
|
18146
|
+
const DocSectionSettingPanelOperation = {
|
|
18147
|
+
id: "sidebar.operation.doc-section-setting-panel",
|
|
18148
|
+
type: CommandType.OPERATION,
|
|
18149
|
+
handler: (accessor) => {
|
|
18150
|
+
accessor.get(DocSectionSettingController).openPanel();
|
|
18151
|
+
return true;
|
|
18152
|
+
}
|
|
18153
|
+
};
|
|
18154
|
+
|
|
17738
18155
|
//#endregion
|
|
17739
18156
|
//#region src/menu/context-menu.ts
|
|
17740
18157
|
const getDisableOnCollapsedObservable = (accessor) => {
|
|
@@ -19492,6 +19909,9 @@ const menuSchema = {
|
|
|
19492
19909
|
|
|
19493
19910
|
//#endregion
|
|
19494
19911
|
//#region src/shortcuts/utils.ts
|
|
19912
|
+
function whenTextEditorFocused(contextService) {
|
|
19913
|
+
return contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && !contextService.getContextValue(FOCUSING_COMMON_DRAWINGS) && (contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(EDITOR_ACTIVATED) || contextService.getContextValue(FOCUSING_FX_BAR_EDITOR));
|
|
19914
|
+
}
|
|
19495
19915
|
function whenDocAndEditorFocused(contextService) {
|
|
19496
19916
|
return contextService.getContextValue(FOCUSING_DOC) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && !contextService.getContextValue(FOCUSING_COMMON_DRAWINGS);
|
|
19497
19917
|
}
|
|
@@ -19506,6 +19926,11 @@ const TabShortCut = {
|
|
|
19506
19926
|
binding: KeyCode.TAB,
|
|
19507
19927
|
preconditions: whenDocAndEditorFocused
|
|
19508
19928
|
};
|
|
19929
|
+
const UpdateDocFieldsShortcut = {
|
|
19930
|
+
id: UpdateSelectedDocFieldsCommand.id,
|
|
19931
|
+
binding: KeyCode.F9,
|
|
19932
|
+
preconditions: whenDocAndEditorFocused
|
|
19933
|
+
};
|
|
19509
19934
|
const ShiftTabShortCut = {
|
|
19510
19935
|
id: TabCommand.id,
|
|
19511
19936
|
binding: KeyCode.TAB | MetaKeys.SHIFT,
|
|
@@ -20515,21 +20940,6 @@ function DocSideMenuContent() {
|
|
|
20515
20940
|
|
|
20516
20941
|
//#endregion
|
|
20517
20942
|
//#region src/controllers/ui.controller.ts
|
|
20518
|
-
/**
|
|
20519
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
20520
|
-
*
|
|
20521
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
20522
|
-
* you may not use this file except in compliance with the License.
|
|
20523
|
-
* You may obtain a copy of the License at
|
|
20524
|
-
*
|
|
20525
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20526
|
-
*
|
|
20527
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
20528
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20529
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20530
|
-
* See the License for the specific language governing permissions and
|
|
20531
|
-
* limitations under the License.
|
|
20532
|
-
*/
|
|
20533
20943
|
let DocUIController = class DocUIController extends Disposable {
|
|
20534
20944
|
constructor(_injector, _commandService, _layoutService, _menuManagerService, _uiPartsService, _univerInstanceService, _shortcutService, _configService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
20535
20945
|
super();
|
|
@@ -20551,6 +20961,7 @@ let DocUIController = class DocUIController extends Disposable {
|
|
|
20551
20961
|
_initMenus() {
|
|
20552
20962
|
this._menuManagerService.appendRootMenu(floatToolbarMenuSchema);
|
|
20553
20963
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
20964
|
+
this._menuManagerService.mergeMenu(headerFooterRibbonSchema);
|
|
20554
20965
|
}
|
|
20555
20966
|
_initShortCut() {
|
|
20556
20967
|
[
|
|
@@ -20566,7 +20977,8 @@ let DocUIController = class DocUIController extends Disposable {
|
|
|
20566
20977
|
AlignLeftShortCut,
|
|
20567
20978
|
OrderListShortCut,
|
|
20568
20979
|
BulletListShortCut,
|
|
20569
|
-
TabShortCut
|
|
20980
|
+
TabShortCut,
|
|
20981
|
+
UpdateDocFieldsShortcut
|
|
20570
20982
|
].forEach((shortcut) => {
|
|
20571
20983
|
this.disposeWithMe(this._shortcutService.registerShortcut(shortcut));
|
|
20572
20984
|
});
|
|
@@ -20575,6 +20987,7 @@ let DocUIController = class DocUIController extends Disposable {
|
|
|
20575
20987
|
this._initMenus();
|
|
20576
20988
|
this._initFocusHandler();
|
|
20577
20989
|
this._initCommands();
|
|
20990
|
+
this._initDateTimeFields();
|
|
20578
20991
|
this._initUiParts();
|
|
20579
20992
|
this._initShortCut();
|
|
20580
20993
|
}
|
|
@@ -20583,10 +20996,25 @@ let DocUIController = class DocUIController extends Disposable {
|
|
|
20583
20996
|
OpenDocPermissionPanelOperation,
|
|
20584
20997
|
OpenDocParagraphPermissionOperation,
|
|
20585
20998
|
CoreHeaderFooterCommand,
|
|
20999
|
+
InsertHeaderFooterFieldCommand,
|
|
21000
|
+
RefreshHeaderFooterFieldsCommand,
|
|
21001
|
+
UpdateSelectedDocFieldsCommand,
|
|
20586
21002
|
OpenHeaderFooterPanelCommand,
|
|
20587
|
-
|
|
21003
|
+
DocHeaderFooterRibbonOperation
|
|
20588
21004
|
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
|
|
20589
21005
|
}
|
|
21006
|
+
_initDateTimeFields() {
|
|
21007
|
+
const refreshed = /* @__PURE__ */ new WeakSet();
|
|
21008
|
+
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).subscribe((model) => {
|
|
21009
|
+
if (model && !refreshed.has(model)) {
|
|
21010
|
+
refreshed.add(model);
|
|
21011
|
+
this._commandService.syncExecuteCommand(RefreshHeaderFooterFieldsCommand.id, {
|
|
21012
|
+
unitId: model.getUnitId(),
|
|
21013
|
+
onOpen: true
|
|
21014
|
+
});
|
|
21015
|
+
}
|
|
21016
|
+
}));
|
|
21017
|
+
}
|
|
20590
21018
|
_initFocusHandler() {
|
|
20591
21019
|
this.disposeWithMe(this._layoutService.registerFocusHandler(UniverInstanceType.UNIVER_DOC, (unitId) => {
|
|
20592
21020
|
if (this._shouldPreserveEmbedFocus(unitId)) return;
|
|
@@ -20884,7 +21312,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
|
|
|
20884
21312
|
//#endregion
|
|
20885
21313
|
//#region package.json
|
|
20886
21314
|
var name = "@univerjs/docs-ui";
|
|
20887
|
-
var version = "1.0.
|
|
21315
|
+
var version = "1.0.4";
|
|
20888
21316
|
|
|
20889
21317
|
//#endregion
|
|
20890
21318
|
//#region src/commands/commands/doc-paragraph-setting.command.ts
|
|
@@ -21131,8 +21559,8 @@ var HeaderFooterContentCover = class extends BaseObject {
|
|
|
21131
21559
|
right: pageLeft + page.pageWidth,
|
|
21132
21560
|
bottom: pageTop + page.pageHeight
|
|
21133
21561
|
});
|
|
21134
|
-
const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.pageWidth);
|
|
21135
|
-
const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.pageWidth);
|
|
21562
|
+
const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.headerLayoutKey ?? page.pageWidth);
|
|
21563
|
+
const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.footerLayoutKey ?? page.pageWidth);
|
|
21136
21564
|
const local = [];
|
|
21137
21565
|
if (header) this._collectTextAndTables(header, pageLeft + page.marginLeft, pageTop + header.marginTop, local);
|
|
21138
21566
|
if (footer) this._collectTextAndTables(footer, pageLeft + page.marginLeft, pageTop + page.pageHeight - footer.height - footer.marginBottom, local);
|
|
@@ -21590,7 +22018,7 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
|
|
|
21590
22018
|
const body = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
21591
22019
|
if (body == null) return;
|
|
21592
22020
|
const dataStreamLength = body.dataStream.length ?? Number.POSITIVE_INFINITY;
|
|
21593
|
-
const customRanges =
|
|
22021
|
+
const customRanges = body.customRanges ?? [];
|
|
21594
22022
|
if (granularity !== "character") {
|
|
21595
22023
|
const nextOffset = this._getCursorOffsetByGranularity(skeleton, focusOffset, direction, granularity, normalizedSegmentId, normalizedSegmentPage, dataStreamLength, body.dataStream);
|
|
21596
22024
|
if (nextOffset == null || nextOffset === focusOffset) return;
|
|
@@ -21662,7 +22090,7 @@ let DocMoveCursorController = class DocMoveCursorController extends Disposable {
|
|
|
21662
22090
|
const body = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
|
|
21663
22091
|
if (body == null) return;
|
|
21664
22092
|
const dataStreamLength = body.dataStream.length ?? Number.POSITIVE_INFINITY;
|
|
21665
|
-
const customRanges =
|
|
22093
|
+
const customRanges = body.customRanges ?? [];
|
|
21666
22094
|
if (granularity !== "character") {
|
|
21667
22095
|
let cursorOffset;
|
|
21668
22096
|
if (!activeRange.collapsed || allRanges.length > 1) {
|
|
@@ -22285,26 +22713,33 @@ function DocPasteOptions() {
|
|
|
22285
22713
|
const commandService = useDependency(ICommandService);
|
|
22286
22714
|
const localeService = useDependency(LocaleService);
|
|
22287
22715
|
const layoutService = useDependency(ILayoutService);
|
|
22716
|
+
const editorService = useDependency(IEditorService);
|
|
22288
22717
|
const state = useObservable(clipboard.pasteOptions$, null);
|
|
22289
22718
|
const [busy, setBusy] = useState(false);
|
|
22290
22719
|
const [open, setOpen] = useState(false);
|
|
22720
|
+
const focusEditor = () => {
|
|
22721
|
+
const editor = state && clipboard.isPasteOptionsEnabled(state.unitId) && editorService.getEditor(state.unitId);
|
|
22722
|
+
if (editor) editor.focus();
|
|
22723
|
+
else layoutService.focus();
|
|
22724
|
+
};
|
|
22291
22725
|
const changeMode = async (value) => {
|
|
22292
22726
|
setBusy(true);
|
|
22293
22727
|
try {
|
|
22294
22728
|
await commandService.executeCommand(DocChangePasteModeCommand.id, { value });
|
|
22295
22729
|
} finally {
|
|
22296
22730
|
setBusy(false);
|
|
22297
|
-
|
|
22731
|
+
focusEditor();
|
|
22298
22732
|
}
|
|
22299
22733
|
};
|
|
22300
22734
|
if (!state) return null;
|
|
22301
22735
|
return /* @__PURE__ */ jsx(DropdownMenu, {
|
|
22736
|
+
"data-u-editor-interaction-boundary": "true",
|
|
22302
22737
|
align: "start",
|
|
22303
22738
|
open,
|
|
22304
22739
|
onOpenChange: setOpen,
|
|
22305
22740
|
onCloseAutoFocus: (event) => {
|
|
22306
22741
|
event.preventDefault();
|
|
22307
|
-
|
|
22742
|
+
focusEditor();
|
|
22308
22743
|
},
|
|
22309
22744
|
onEscapeKeyDown: () => clipboard.dismissPasteOptions(),
|
|
22310
22745
|
items: DOC_PASTE_OPTIONS.map((option) => ({
|
|
@@ -22316,6 +22751,7 @@ function DocPasteOptions() {
|
|
|
22316
22751
|
onSelect: () => changeMode(option.value)
|
|
22317
22752
|
})),
|
|
22318
22753
|
children: /* @__PURE__ */ jsxs(Button, {
|
|
22754
|
+
"data-u-editor-interaction-boundary": "true",
|
|
22319
22755
|
size: "small",
|
|
22320
22756
|
disabled: busy,
|
|
22321
22757
|
"aria-label": localeService.t("docs-ui.pasteOptions.title"),
|
|
@@ -22324,7 +22760,7 @@ function DocPasteOptions() {
|
|
|
22324
22760
|
onKeyDown: (event) => {
|
|
22325
22761
|
if (event.key === "Escape") {
|
|
22326
22762
|
clipboard.dismissPasteOptions();
|
|
22327
|
-
|
|
22763
|
+
focusEditor();
|
|
22328
22764
|
}
|
|
22329
22765
|
},
|
|
22330
22766
|
className: "univer-shadow-sm",
|
|
@@ -22583,28 +23019,37 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22583
23019
|
page
|
|
22584
23020
|
};
|
|
22585
23021
|
};
|
|
22586
|
-
const [
|
|
22587
|
-
|
|
22588
|
-
const
|
|
22589
|
-
|
|
22590
|
-
|
|
22591
|
-
|
|
22592
|
-
|
|
22593
|
-
|
|
23022
|
+
const [, refresh] = useReducer((revision) => revision + 1, 0);
|
|
23023
|
+
useEffect(() => {
|
|
23024
|
+
const commandListener = commandService.onCommandExecuted((command) => {
|
|
23025
|
+
var _command$params;
|
|
23026
|
+
if (command.id === RichTextEditingMutation.id && ((_command$params = command.params) === null || _command$params === void 0 ? void 0 : _command$params.unitId) === unitId) refresh();
|
|
23027
|
+
});
|
|
23028
|
+
const segmentListener = docSelectionRenderService.segmentContext$.subscribe(() => refresh());
|
|
23029
|
+
return () => {
|
|
23030
|
+
commandListener.dispose();
|
|
23031
|
+
segmentListener.unsubscribe();
|
|
22594
23032
|
};
|
|
22595
|
-
}
|
|
23033
|
+
}, [
|
|
23034
|
+
commandService,
|
|
23035
|
+
docSelectionRenderService,
|
|
23036
|
+
unitId
|
|
23037
|
+
]);
|
|
22596
23038
|
const sectionContext = getCurrentSectionContext();
|
|
23039
|
+
const config = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config;
|
|
23040
|
+
const options = {
|
|
23041
|
+
marginHeader: (config === null || config === void 0 ? void 0 : config.marginHeader) ?? 0,
|
|
23042
|
+
marginFooter: (config === null || config === void 0 ? void 0 : config.marginFooter) ?? 0,
|
|
23043
|
+
useFirstPageHeaderFooter: (config === null || config === void 0 ? void 0 : config.useFirstPageHeaderFooter) ?? BooleanNumber.FALSE,
|
|
23044
|
+
evenAndOddHeaders: (config === null || config === void 0 ? void 0 : config.evenAndOddHeaders) ?? BooleanNumber.FALSE
|
|
23045
|
+
};
|
|
22597
23046
|
const headerFooterKind = ((_renderManagerService2 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.with(DocSkeletonManagerService)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.getViewModel()) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.getEditArea()) === DocumentEditArea.FOOTER ? "footer" : "header";
|
|
22598
23047
|
const variant = getHeaderFooterVariant((sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config) ?? {}, docSelectionRenderService.getSegmentPage(), sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page);
|
|
22599
23048
|
const referenceKey = getSectionHeaderFooterReferenceKey(headerFooterKind, variant);
|
|
22600
23049
|
const canLinkToPrevious = ((sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionIndex) ?? -1) > 0;
|
|
22601
|
-
const
|
|
22602
|
-
const handleCheckboxChange = (val, type) => {
|
|
23050
|
+
const linkedToPrevious = canLinkToPrevious && !(sectionContext === null || sectionContext === void 0 || (_sectionContext$secti = sectionContext.section) === null || _sectionContext$secti === void 0 ? void 0 : _sectionContext$secti[referenceKey]);
|
|
23051
|
+
const handleCheckboxChange = async (val, type) => {
|
|
22603
23052
|
var _renderManagerService3;
|
|
22604
|
-
setOptions((prev) => ({
|
|
22605
|
-
...prev,
|
|
22606
|
-
[type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE
|
|
22607
|
-
}));
|
|
22608
23053
|
const sectionContext = getCurrentSectionContext();
|
|
22609
23054
|
const documentStyle = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config;
|
|
22610
23055
|
const docSkeletonManagerService = (_renderManagerService3 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService3 === void 0 ? void 0 : _renderManagerService3.with(DocSkeletonManagerService);
|
|
@@ -22629,7 +23074,7 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22629
23074
|
if (needCreateHeaderFooter) {
|
|
22630
23075
|
const segmentId = generateRandomId(6);
|
|
22631
23076
|
if (needChangeSegmentId) docSelectionRenderService.setSegment(segmentId);
|
|
22632
|
-
commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
23077
|
+
await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
22633
23078
|
unitId,
|
|
22634
23079
|
segmentId,
|
|
22635
23080
|
headerFooterProps: { [type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE },
|
|
@@ -22643,7 +23088,7 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22643
23088
|
[type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE
|
|
22644
23089
|
}, editArea, segmentPageIndex, sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page);
|
|
22645
23090
|
if (needFocusSegmentId && needFocusSegmentId !== prevSegmentId) docSelectionRenderService.setSegment(needFocusSegmentId);
|
|
22646
|
-
commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
23091
|
+
await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
22647
23092
|
unitId,
|
|
22648
23093
|
headerFooterProps: { [type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE },
|
|
22649
23094
|
sectionId: sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionId
|
|
@@ -22652,21 +23097,16 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22652
23097
|
layoutService.focus();
|
|
22653
23098
|
};
|
|
22654
23099
|
const handleMarginChange = async (val, type) => {
|
|
22655
|
-
var
|
|
22656
|
-
setOptions((prev) => ({
|
|
22657
|
-
...prev,
|
|
22658
|
-
[type]: val
|
|
22659
|
-
}));
|
|
23100
|
+
var _getCurrentSectionCon;
|
|
22660
23101
|
await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
22661
23102
|
unitId,
|
|
22662
23103
|
headerFooterProps: { [type]: val },
|
|
22663
|
-
sectionId: (
|
|
23104
|
+
sectionId: (_getCurrentSectionCon = getCurrentSectionContext()) === null || _getCurrentSectionCon === void 0 ? void 0 : _getCurrentSectionCon.sectionId
|
|
22664
23105
|
});
|
|
22665
|
-
docSelectionRenderService.removeAllRanges();
|
|
22666
23106
|
docSelectionRenderService.blur();
|
|
22667
23107
|
};
|
|
22668
23108
|
const closeHeaderFooter = () => {
|
|
22669
|
-
commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId });
|
|
23109
|
+
return commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId });
|
|
22670
23110
|
};
|
|
22671
23111
|
const handleLinkToPreviousChange = async (linked) => {
|
|
22672
23112
|
var _renderManagerService4;
|
|
@@ -22685,7 +23125,6 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22685
23125
|
linkedToPrevious: linked,
|
|
22686
23126
|
...linked ? {} : { segmentId }
|
|
22687
23127
|
})) return;
|
|
22688
|
-
setLinkedToPrevious(linked);
|
|
22689
23128
|
docSelectionRenderService.setSegment(linked ? previousSegmentId ?? "" : segmentId);
|
|
22690
23129
|
layoutService.focus();
|
|
22691
23130
|
};
|
|
@@ -25387,9 +25826,9 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
|
|
|
25387
25826
|
this._context = _context;
|
|
25388
25827
|
this._clipboard = _clipboard;
|
|
25389
25828
|
_defineProperty(this, "_popup", void 0);
|
|
25390
|
-
if (isInternalEditorID(_context.unitId)) return;
|
|
25391
25829
|
const mobile = contextService.getContextValue(MOBILE_UI_MODE) === true;
|
|
25392
25830
|
this.disposeWithMe(selection.onKeydown$.subscribe(({ event }) => {
|
|
25831
|
+
if (!this._clipboard.isPasteOptionsEnabled(this._context.unitId)) return;
|
|
25393
25832
|
const key = event;
|
|
25394
25833
|
if ((key.ctrlKey || key.metaKey) && key.shiftKey && key.key.toLowerCase() === "v") this._clipboard.setNextPasteMode("text");
|
|
25395
25834
|
else if (![
|
|
@@ -25402,12 +25841,17 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
|
|
|
25402
25841
|
this._clipboard.dismissPasteOptions();
|
|
25403
25842
|
}
|
|
25404
25843
|
}));
|
|
25405
|
-
this.disposeWithMe(selection.onInputBefore$.subscribe(() =>
|
|
25844
|
+
this.disposeWithMe(selection.onInputBefore$.subscribe(() => {
|
|
25845
|
+
if (this._clipboard.isPasteOptionsEnabled(this._context.unitId)) this._clipboard.dismissPasteOptions();
|
|
25846
|
+
}));
|
|
25406
25847
|
this.disposeWithMe(selection.onPointerDown$.subscribe(() => {
|
|
25848
|
+
if (!this._clipboard.isPasteOptionsEnabled(this._context.unitId)) return;
|
|
25407
25849
|
this._clipboard.setNextPasteMode("source");
|
|
25408
25850
|
if (!mobile) this._clipboard.dismissPasteOptions();
|
|
25409
25851
|
}));
|
|
25410
|
-
this.disposeWithMe(selection.onBlur$.subscribe(() =>
|
|
25852
|
+
this.disposeWithMe(selection.onBlur$.subscribe(() => {
|
|
25853
|
+
if (this._clipboard.isPasteOptionsEnabled(this._context.unitId)) this._clipboard.setNextPasteMode("source");
|
|
25854
|
+
}));
|
|
25411
25855
|
this.disposeWithMe(this._clipboard.pasteOptions$.subscribe((state) => {
|
|
25412
25856
|
var _this$_popup;
|
|
25413
25857
|
(_this$_popup = this._popup) === null || _this$_popup === void 0 || _this$_popup.dispose();
|
|
@@ -25427,7 +25871,7 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
|
|
|
25427
25871
|
this.disposeWithMe(() => {
|
|
25428
25872
|
var _this$_popup2;
|
|
25429
25873
|
(_this$_popup2 = this._popup) === null || _this$_popup2 === void 0 || _this$_popup2.dispose();
|
|
25430
|
-
this._clipboard.dismissPasteOptions();
|
|
25874
|
+
if (this._popup) this._clipboard.dismissPasteOptions();
|
|
25431
25875
|
});
|
|
25432
25876
|
}
|
|
25433
25877
|
};
|
|
@@ -26464,8 +26908,8 @@ var DocPrintInterceptorService = class extends Disposable {
|
|
|
26464
26908
|
const page = data.pages[pageIndex];
|
|
26465
26909
|
if (!page) return drawingIds;
|
|
26466
26910
|
collectPageDrawingIds(page, drawingIds);
|
|
26467
|
-
const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.pageWidth);
|
|
26468
|
-
const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.pageWidth);
|
|
26911
|
+
const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.headerLayoutKey ?? page.pageWidth);
|
|
26912
|
+
const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.footerLayoutKey ?? page.pageWidth);
|
|
26469
26913
|
if (header) collectPageDrawingIds(header, drawingIds);
|
|
26470
26914
|
if (footer) collectPageDrawingIds(footer, drawingIds);
|
|
26471
26915
|
return drawingIds;
|
|
@@ -27466,6 +27910,319 @@ UniverDocsMobileUIPlugin = __decorate([
|
|
|
27466
27910
|
__decorateParam(4, IConfigService)
|
|
27467
27911
|
], UniverDocsMobileUIPlugin);
|
|
27468
27912
|
|
|
27913
|
+
//#endregion
|
|
27914
|
+
//#region src/views/header-footer/panel/DocHeaderFooterFields.tsx
|
|
27915
|
+
function DocHeaderFooterFields({ unitId, disabled }) {
|
|
27916
|
+
const localeService = useDependency(LocaleService);
|
|
27917
|
+
useObservable(localeService.currentLocale$);
|
|
27918
|
+
const commands = useDependency(ICommandService);
|
|
27919
|
+
const layout = useDependency(ILayoutService);
|
|
27920
|
+
const shortcuts = useDependency(IShortcutService);
|
|
27921
|
+
const selections = useDependency(DocSelectionManagerService);
|
|
27922
|
+
const instances = useDependency(IUniverInstanceService);
|
|
27923
|
+
const [target, setTarget] = useState(null);
|
|
27924
|
+
const [format, setFormat] = useState("short");
|
|
27925
|
+
const [automatic, setAutomatic] = useState(true);
|
|
27926
|
+
const [error, setError] = useState(false);
|
|
27927
|
+
const [previewDate, setPreviewDate] = useState(() => /* @__PURE__ */ new Date());
|
|
27928
|
+
const locale = LOCALE_META[localeService.getCurrentLocale()].tag;
|
|
27929
|
+
const dialogOpen = target !== null;
|
|
27930
|
+
const dialogFocusRef = useRef(null);
|
|
27931
|
+
useEffect(() => {
|
|
27932
|
+
var _instances$getFocused;
|
|
27933
|
+
if (dialogOpen) return;
|
|
27934
|
+
const focus = dialogFocusRef.current;
|
|
27935
|
+
dialogFocusRef.current = null;
|
|
27936
|
+
if ((focus === null || focus === void 0 ? void 0 : focus.unitId) === unitId && instances.getUnit(unitId) && ((_instances$getFocused = instances.getFocusedUnit()) === null || _instances$getFocused === void 0 ? void 0 : _instances$getFocused.getUnitId()) === focus.focusedUnitId) layout.focus(unitId);
|
|
27937
|
+
}, [
|
|
27938
|
+
dialogOpen,
|
|
27939
|
+
instances,
|
|
27940
|
+
layout,
|
|
27941
|
+
unitId
|
|
27942
|
+
]);
|
|
27943
|
+
useEffect(() => {
|
|
27944
|
+
if (!dialogOpen) return;
|
|
27945
|
+
const escape = shortcuts.forceEscape();
|
|
27946
|
+
return () => escape.dispose();
|
|
27947
|
+
}, [dialogOpen, shortcuts]);
|
|
27948
|
+
function restoreFocus(event) {
|
|
27949
|
+
event.preventDefault();
|
|
27950
|
+
layout.focus(unitId);
|
|
27951
|
+
}
|
|
27952
|
+
function openDateTime() {
|
|
27953
|
+
var _instances$getUnit, _instances$getFocused2;
|
|
27954
|
+
const selection = selections.getActiveTextRange();
|
|
27955
|
+
const body = (_instances$getUnit = instances.getUnit(unitId)) === null || _instances$getUnit === void 0 || (_instances$getUnit = _instances$getUnit.getSelfOrHeaderFooterModel(selection === null || selection === void 0 ? void 0 : selection.segmentId)) === null || _instances$getUnit === void 0 ? void 0 : _instances$getUnit.getBody();
|
|
27956
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.segmentId) || !body) return;
|
|
27957
|
+
dialogFocusRef.current = {
|
|
27958
|
+
unitId,
|
|
27959
|
+
focusedUnitId: (_instances$getFocused2 = instances.getFocusedUnit()) === null || _instances$getFocused2 === void 0 ? void 0 : _instances$getFocused2.getUnitId()
|
|
27960
|
+
};
|
|
27961
|
+
setTarget({
|
|
27962
|
+
unitId,
|
|
27963
|
+
selection: { ...selection },
|
|
27964
|
+
segmentId: selection.segmentId,
|
|
27965
|
+
segmentPage: selection.segmentPage,
|
|
27966
|
+
expectedDataStream: body.dataStream
|
|
27967
|
+
});
|
|
27968
|
+
setPreviewDate(/* @__PURE__ */ new Date());
|
|
27969
|
+
setError(false);
|
|
27970
|
+
}
|
|
27971
|
+
async function insertDateTime() {
|
|
27972
|
+
if (!target) return;
|
|
27973
|
+
if (await commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
|
|
27974
|
+
...target,
|
|
27975
|
+
fieldType: format === "time" ? "TIME" : "DATE",
|
|
27976
|
+
format,
|
|
27977
|
+
automatic
|
|
27978
|
+
})) setTarget(null);
|
|
27979
|
+
else setError(true);
|
|
27980
|
+
}
|
|
27981
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
27982
|
+
className: "univer-flex univer-flex-col univer-gap-1 univer-text-xs",
|
|
27983
|
+
children: [
|
|
27984
|
+
/* @__PURE__ */ jsx(DropdownMenu, {
|
|
27985
|
+
onCloseAutoFocus: restoreFocus,
|
|
27986
|
+
disabled,
|
|
27987
|
+
items: [
|
|
27988
|
+
{
|
|
27989
|
+
type: "item",
|
|
27990
|
+
children: localeService.t("docs-ui.headerFooter.currentPage"),
|
|
27991
|
+
onSelect: () => commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
|
|
27992
|
+
unitId,
|
|
27993
|
+
fieldType: "PAGE"
|
|
27994
|
+
})
|
|
27995
|
+
},
|
|
27996
|
+
{
|
|
27997
|
+
type: "item",
|
|
27998
|
+
children: localeService.t("docs-ui.headerFooter.totalPages"),
|
|
27999
|
+
onSelect: () => commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
|
|
28000
|
+
unitId,
|
|
28001
|
+
fieldType: "NUMPAGES"
|
|
28002
|
+
})
|
|
28003
|
+
},
|
|
28004
|
+
{ type: "separator" },
|
|
28005
|
+
{
|
|
28006
|
+
type: "item",
|
|
28007
|
+
children: localeService.t("docs-ui.headerFooter.refreshFields"),
|
|
28008
|
+
onSelect: () => commands.executeCommand(RefreshHeaderFooterFieldsCommand.id, { unitId })
|
|
28009
|
+
}
|
|
28010
|
+
],
|
|
28011
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
28012
|
+
className: "univer-justify-start",
|
|
28013
|
+
"data-u-command": InsertHeaderFooterFieldCommand.id,
|
|
28014
|
+
size: "small",
|
|
28015
|
+
variant: "text",
|
|
28016
|
+
disabled,
|
|
28017
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28018
|
+
children: [
|
|
28019
|
+
/* @__PURE__ */ jsx(NumberIcon, { "aria-hidden": "true" }),
|
|
28020
|
+
/* @__PURE__ */ jsx("span", {
|
|
28021
|
+
className: "univer-flex-1 univer-text-start",
|
|
28022
|
+
children: localeService.t("docs-ui.headerFooter.pageNumber")
|
|
28023
|
+
}),
|
|
28024
|
+
/* @__PURE__ */ jsx(MoreDownIcon, { "aria-hidden": "true" })
|
|
28025
|
+
]
|
|
28026
|
+
})
|
|
28027
|
+
}),
|
|
28028
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
28029
|
+
className: "univer-justify-start",
|
|
28030
|
+
"data-u-command": InsertHeaderFooterFieldCommand.id,
|
|
28031
|
+
size: "small",
|
|
28032
|
+
variant: "text",
|
|
28033
|
+
disabled,
|
|
28034
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28035
|
+
onClick: openDateTime,
|
|
28036
|
+
children: [/* @__PURE__ */ jsx(CalendarIcon, { "aria-hidden": "true" }), localeService.t("docs-ui.headerFooter.dateTime")]
|
|
28037
|
+
}),
|
|
28038
|
+
/* @__PURE__ */ jsx(Dialog, {
|
|
28039
|
+
open: dialogOpen,
|
|
28040
|
+
width: 360,
|
|
28041
|
+
title: localeService.t("docs-ui.headerFooter.dateTime"),
|
|
28042
|
+
showOk: true,
|
|
28043
|
+
showCancel: true,
|
|
28044
|
+
onClose: () => setTarget(null),
|
|
28045
|
+
onCancel: () => setTarget(null),
|
|
28046
|
+
onOk: insertDateTime,
|
|
28047
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
28048
|
+
className: "univer-flex univer-flex-col univer-gap-4",
|
|
28049
|
+
children: [
|
|
28050
|
+
/* @__PURE__ */ jsx(DropdownMenu, {
|
|
28051
|
+
align: "start",
|
|
28052
|
+
className: "univer-w-[--radix-popper-anchor-width]",
|
|
28053
|
+
items: [{
|
|
28054
|
+
type: "radio",
|
|
28055
|
+
value: format,
|
|
28056
|
+
hideIndicator: true,
|
|
28057
|
+
onSelect: (value) => setFormat(value),
|
|
28058
|
+
options: [
|
|
28059
|
+
"short",
|
|
28060
|
+
"long",
|
|
28061
|
+
"time"
|
|
28062
|
+
].map((value) => ({
|
|
28063
|
+
value,
|
|
28064
|
+
label: createDateTimeField(value, locale, previewDate).cachedResult
|
|
28065
|
+
}))
|
|
28066
|
+
}],
|
|
28067
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
28068
|
+
"aria-label": localeService.t("docs-ui.headerFooter.dateTime"),
|
|
28069
|
+
className: selectClassName,
|
|
28070
|
+
"data-u-comp": "select",
|
|
28071
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
28072
|
+
className: "univer-flex-1 univer-truncate univer-text-start",
|
|
28073
|
+
children: createDateTimeField(format, locale, previewDate).cachedResult
|
|
28074
|
+
}), /* @__PURE__ */ jsx(MoreDownIcon, { "aria-hidden": "true" })]
|
|
28075
|
+
})
|
|
28076
|
+
}),
|
|
28077
|
+
/* @__PURE__ */ jsx(Checkbox, {
|
|
28078
|
+
checked: automatic,
|
|
28079
|
+
onChange: (value) => setAutomatic(Boolean(value)),
|
|
28080
|
+
children: localeService.t("docs-ui.headerFooter.updateAutomatically")
|
|
28081
|
+
}),
|
|
28082
|
+
error && /* @__PURE__ */ jsx("p", {
|
|
28083
|
+
role: "alert",
|
|
28084
|
+
children: localeService.t("docs-ui.headerFooter.insertFailed")
|
|
28085
|
+
})
|
|
28086
|
+
]
|
|
28087
|
+
})
|
|
28088
|
+
})
|
|
28089
|
+
]
|
|
28090
|
+
});
|
|
28091
|
+
}
|
|
28092
|
+
|
|
28093
|
+
//#endregion
|
|
28094
|
+
//#region src/views/header-footer/panel/DocHeaderFooterRibbonControl.tsx
|
|
28095
|
+
function DocHeaderFooterRibbonControl(props) {
|
|
28096
|
+
const instances = useDependency(IUniverInstanceService);
|
|
28097
|
+
const localeService = useDependency(LocaleService);
|
|
28098
|
+
useObservable(localeService.currentLocale$);
|
|
28099
|
+
const document = useObservable(() => instances.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), void 0, false, [instances]);
|
|
28100
|
+
const containerRef = useRef(null);
|
|
28101
|
+
const [compact, setCompact] = useState(false);
|
|
28102
|
+
const { kind } = props;
|
|
28103
|
+
useEffect(() => {
|
|
28104
|
+
var _containerRef$current;
|
|
28105
|
+
const toolbar = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest("[role=\"toolbar\"]");
|
|
28106
|
+
if (!toolbar || kind === "insertion") return;
|
|
28107
|
+
const thresholds = {
|
|
28108
|
+
position: 1100,
|
|
28109
|
+
options: 900,
|
|
28110
|
+
navigation: 650
|
|
28111
|
+
};
|
|
28112
|
+
const resize = () => setCompact(toolbar.getBoundingClientRect().width < thresholds[kind]);
|
|
28113
|
+
const observer = new ResizeObserver(resize);
|
|
28114
|
+
observer.observe(toolbar);
|
|
28115
|
+
return () => observer.disconnect();
|
|
28116
|
+
}, [kind, document]);
|
|
28117
|
+
if (!document) return null;
|
|
28118
|
+
const content = /* @__PURE__ */ jsx(HeaderFooterRibbonControl, {
|
|
28119
|
+
...props,
|
|
28120
|
+
unitId: document.getUnitId()
|
|
28121
|
+
}, document.getUnitId());
|
|
28122
|
+
return /* @__PURE__ */ jsx("div", {
|
|
28123
|
+
ref: containerRef,
|
|
28124
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28125
|
+
className: "univer-flex univer-items-center univer-whitespace-nowrap",
|
|
28126
|
+
children: compact && kind !== "insertion" ? /* @__PURE__ */ jsx(DropdownMenu, {
|
|
28127
|
+
items: [{
|
|
28128
|
+
type: "custom",
|
|
28129
|
+
className: "univer-p-2",
|
|
28130
|
+
children: content
|
|
28131
|
+
}],
|
|
28132
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
28133
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28134
|
+
size: "small",
|
|
28135
|
+
variant: "text",
|
|
28136
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28137
|
+
children: localeService.t(`docs-ui.headerFooter.${kind}`)
|
|
28138
|
+
})
|
|
28139
|
+
}) : content
|
|
28140
|
+
});
|
|
28141
|
+
}
|
|
28142
|
+
function HeaderFooterRibbonControl({ kind, unitId }) {
|
|
28143
|
+
var _instances$getUnit, _renders$getRenderUni;
|
|
28144
|
+
const localeService = useDependency(LocaleService);
|
|
28145
|
+
const commandService = useDependency(ICommandService);
|
|
28146
|
+
const renders = useDependency(IRenderManagerService);
|
|
28147
|
+
const permissionService = useDependency(IPermissionService);
|
|
28148
|
+
useObservable(permissionService.permissionPointUpdate$);
|
|
28149
|
+
const instances = useDependency(IUniverInstanceService);
|
|
28150
|
+
const disabled = Boolean((_instances$getUnit = instances.getUnit(unitId)) === null || _instances$getUnit === void 0 ? void 0 : _instances$getUnit.getSnapshot().disabled) || !getDocumentPermissionValue(permissionService, unitId, unitId, UnitAction.Edit);
|
|
28151
|
+
const { canLinkToPrevious, linkedToPrevious, options, handleLinkToPreviousChange, handleCheckboxChange, handleMarginChange } = useHeaderFooterOptions(unitId);
|
|
28152
|
+
const area = (_renders$getRenderUni = renders.getRenderUnitById(unitId)) === null || _renders$getRenderUni === void 0 ? void 0 : _renders$getRenderUni.with(DocSkeletonManagerService).getViewModel().getEditArea();
|
|
28153
|
+
if (kind === "insertion") return /* @__PURE__ */ jsx(DocHeaderFooterFields, {
|
|
28154
|
+
unitId,
|
|
28155
|
+
disabled
|
|
28156
|
+
});
|
|
28157
|
+
if (kind === "navigation") return /* @__PURE__ */ jsxs("div", {
|
|
28158
|
+
className: "univer-grid univer-grid-cols-[auto_auto] univer-items-center univer-gap-x-2 univer-gap-y-1 univer-text-start univer-text-xs",
|
|
28159
|
+
children: [
|
|
28160
|
+
/* @__PURE__ */ jsx(Button, {
|
|
28161
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28162
|
+
size: "small",
|
|
28163
|
+
variant: "text",
|
|
28164
|
+
disabled: disabled || area === DocumentEditArea.HEADER,
|
|
28165
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28166
|
+
onClick: () => commandService.executeCommand(OpenHeaderFooterPanelCommand.id, { editArea: DocumentEditArea.HEADER }),
|
|
28167
|
+
children: localeService.t("docs-ui.headerFooter.goToHeader")
|
|
28168
|
+
}),
|
|
28169
|
+
/* @__PURE__ */ jsx(Checkbox, {
|
|
28170
|
+
disabled: disabled || !canLinkToPrevious,
|
|
28171
|
+
checked: linkedToPrevious,
|
|
28172
|
+
onChange: (value) => handleLinkToPreviousChange(Boolean(value)),
|
|
28173
|
+
children: localeService.t("docs-ui.headerFooter.linkToPrevious")
|
|
28174
|
+
}),
|
|
28175
|
+
/* @__PURE__ */ jsx(Button, {
|
|
28176
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28177
|
+
size: "small",
|
|
28178
|
+
variant: "text",
|
|
28179
|
+
disabled: disabled || area === DocumentEditArea.FOOTER,
|
|
28180
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28181
|
+
onClick: () => commandService.executeCommand(OpenHeaderFooterPanelCommand.id, { editArea: DocumentEditArea.FOOTER }),
|
|
28182
|
+
children: localeService.t("docs-ui.headerFooter.goToFooter")
|
|
28183
|
+
})
|
|
28184
|
+
]
|
|
28185
|
+
});
|
|
28186
|
+
if (kind === "options") return /* @__PURE__ */ jsxs("div", {
|
|
28187
|
+
className: "univer-flex univer-flex-col univer-gap-2 univer-text-start univer-text-xs",
|
|
28188
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
28189
|
+
disabled,
|
|
28190
|
+
checked: options.useFirstPageHeaderFooter === BooleanNumber.TRUE,
|
|
28191
|
+
onChange: (value) => handleCheckboxChange(Boolean(value), "useFirstPageHeaderFooter"),
|
|
28192
|
+
children: localeService.t("docs-ui.headerFooter.firstPageCheckBox")
|
|
28193
|
+
}), /* @__PURE__ */ jsx(Checkbox, {
|
|
28194
|
+
disabled,
|
|
28195
|
+
checked: options.evenAndOddHeaders === BooleanNumber.TRUE,
|
|
28196
|
+
onChange: (value) => handleCheckboxChange(Boolean(value), "evenAndOddHeaders"),
|
|
28197
|
+
children: localeService.t("docs-ui.headerFooter.oddEvenCheckBox")
|
|
28198
|
+
})]
|
|
28199
|
+
});
|
|
28200
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
28201
|
+
className: "univer-flex univer-flex-col univer-gap-1 univer-text-start univer-text-xs",
|
|
28202
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
28203
|
+
className: "univer-grid univer-grid-cols-[1fr_5rem] univer-items-center univer-gap-x-2",
|
|
28204
|
+
children: [/* @__PURE__ */ jsx("span", { children: localeService.t("docs-ui.headerFooter.headerTopMargin") }), /* @__PURE__ */ jsx(InputNumber, {
|
|
28205
|
+
disabled,
|
|
28206
|
+
min: 0,
|
|
28207
|
+
max: 200,
|
|
28208
|
+
precision: 1,
|
|
28209
|
+
value: options.marginHeader,
|
|
28210
|
+
onChange: (value) => handleMarginChange(value ?? 0, "marginHeader")
|
|
28211
|
+
})]
|
|
28212
|
+
}), /* @__PURE__ */ jsxs("label", {
|
|
28213
|
+
className: "univer-grid univer-grid-cols-[1fr_5rem] univer-items-center univer-gap-x-2",
|
|
28214
|
+
children: [/* @__PURE__ */ jsx("span", { children: localeService.t("docs-ui.headerFooter.footerBottomMargin") }), /* @__PURE__ */ jsx(InputNumber, {
|
|
28215
|
+
disabled,
|
|
28216
|
+
min: 0,
|
|
28217
|
+
max: 200,
|
|
28218
|
+
precision: 1,
|
|
28219
|
+
value: options.marginFooter,
|
|
28220
|
+
onChange: (value) => handleMarginChange(value ?? 0, "marginFooter")
|
|
28221
|
+
})]
|
|
28222
|
+
})]
|
|
28223
|
+
});
|
|
28224
|
+
}
|
|
28225
|
+
|
|
27469
28226
|
//#endregion
|
|
27470
28227
|
//#region src/views/paragraph-menu/component-keys.ts
|
|
27471
28228
|
/**
|
|
@@ -29261,6 +30018,7 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
29261
30018
|
BoldIcon,
|
|
29262
30019
|
CopyDoubleIcon,
|
|
29263
30020
|
ColumnIcon,
|
|
30021
|
+
CloseIcon,
|
|
29264
30022
|
CutIcon,
|
|
29265
30023
|
DeleteColumnDoubleIcon,
|
|
29266
30024
|
DeleteIcon,
|
|
@@ -29339,7 +30097,8 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
29339
30097
|
}));
|
|
29340
30098
|
}
|
|
29341
30099
|
_registerComponents() {
|
|
29342
|
-
|
|
30100
|
+
this.disposeWithMe(this._componentManager.register(DOC_HEADER_FOOTER_RIBBON_CONTROL, DocHeaderFooterRibbonControl));
|
|
30101
|
+
if (!this._componentManager.hasDefault("COMPONENT_DOC_HEADER_FOOTER_PANEL")) this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, DocHeaderFooterPanel));
|
|
29343
30102
|
this.disposeWithMe(this._componentManager.register(paragraphSettingIndexKey, ParagraphSettingIndex));
|
|
29344
30103
|
this.disposeWithMe(this._componentManager.register(DOC_SECTION_SETTING_COMPONENT, SectionSettingIndex));
|
|
29345
30104
|
[
|
|
@@ -29357,6 +30116,43 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
29357
30116
|
};
|
|
29358
30117
|
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
29359
30118
|
|
|
30119
|
+
//#endregion
|
|
30120
|
+
//#region src/controllers/doc-header-footer-ribbon.controller.ts
|
|
30121
|
+
let DocHeaderFooterRibbonController = class DocHeaderFooterRibbonController extends Disposable {
|
|
30122
|
+
constructor(_context, skeletonManager, _instanceService, _ribbonService, _renderManager) {
|
|
30123
|
+
super();
|
|
30124
|
+
this._context = _context;
|
|
30125
|
+
this._instanceService = _instanceService;
|
|
30126
|
+
this._ribbonService = _ribbonService;
|
|
30127
|
+
this._renderManager = _renderManager;
|
|
30128
|
+
_defineProperty(this, "_visible", false);
|
|
30129
|
+
this.disposeWithMe(combineLatest([skeletonManager.getViewModel().editAreaChange$, this._instanceService.focused$]).pipe(map(([area, focused]) => focused === this._context.unitId && this._context.unit.getDocumentStyle().documentFlavor === DocumentFlavor.TRADITIONAL && (area === DocumentEditArea.HEADER || area === DocumentEditArea.FOOTER)), distinctUntilChanged()).subscribe((visible) => {
|
|
30130
|
+
if (visible === this._visible) return;
|
|
30131
|
+
this._visible = visible;
|
|
30132
|
+
if (visible) this._ribbonService.showContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB, { activate: true });
|
|
30133
|
+
else if (!this._focusedDocumentEditsHeaderFooter()) this._ribbonService.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
|
|
30134
|
+
}));
|
|
30135
|
+
}
|
|
30136
|
+
_focusedDocumentEditsHeaderFooter() {
|
|
30137
|
+
var _this$_renderManager$;
|
|
30138
|
+
const focused = this._instanceService.getFocusedUnit();
|
|
30139
|
+
if (!focused || focused.type !== UniverInstanceType.UNIVER_DOC || focused.getUnitId() === this._context.unitId) return false;
|
|
30140
|
+
const manager = (_this$_renderManager$ = this._renderManager.getRenderUnitById(focused.getUnitId())) === null || _this$_renderManager$ === void 0 ? void 0 : _this$_renderManager$.with(DocSkeletonManagerService);
|
|
30141
|
+
const area = manager === null || manager === void 0 ? void 0 : manager.getViewModel().getEditArea();
|
|
30142
|
+
return (area === DocumentEditArea.HEADER || area === DocumentEditArea.FOOTER) && (manager === null || manager === void 0 ? void 0 : manager.getViewModel().getDataModel().getDocumentStyle().documentFlavor) === DocumentFlavor.TRADITIONAL;
|
|
30143
|
+
}
|
|
30144
|
+
dispose() {
|
|
30145
|
+
if (this._visible && !this._focusedDocumentEditsHeaderFooter()) this._ribbonService.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
|
|
30146
|
+
super.dispose();
|
|
30147
|
+
}
|
|
30148
|
+
};
|
|
30149
|
+
DocHeaderFooterRibbonController = __decorate([
|
|
30150
|
+
__decorateParam(1, Inject(DocSkeletonManagerService)),
|
|
30151
|
+
__decorateParam(2, IUniverInstanceService),
|
|
30152
|
+
__decorateParam(3, IRibbonService),
|
|
30153
|
+
__decorateParam(4, IRenderManagerService)
|
|
30154
|
+
], DocHeaderFooterRibbonController);
|
|
30155
|
+
|
|
29360
30156
|
//#endregion
|
|
29361
30157
|
//#region src/controllers/format-painter.controller.ts
|
|
29362
30158
|
let DocFormatPainterController = class DocFormatPainterController extends Disposable {
|
|
@@ -29424,6 +30220,83 @@ DocFormatPainterController = __decorate([
|
|
|
29424
30220
|
__decorateParam(7, ICommandService)
|
|
29425
30221
|
], DocFormatPainterController);
|
|
29426
30222
|
|
|
30223
|
+
//#endregion
|
|
30224
|
+
//#region src/controllers/render-controllers/doc-field.render-controller.ts
|
|
30225
|
+
let DocFieldRenderController = class DocFieldRenderController extends Disposable {
|
|
30226
|
+
constructor(_context, _events, _selections, theme, _instances) {
|
|
30227
|
+
super();
|
|
30228
|
+
this._context = _context;
|
|
30229
|
+
this._events = _events;
|
|
30230
|
+
this._selections = _selections;
|
|
30231
|
+
this._instances = _instances;
|
|
30232
|
+
_defineProperty(this, "_hovered", /* @__PURE__ */ new Set());
|
|
30233
|
+
_defineProperty(this, "_shade", "");
|
|
30234
|
+
const documents = this._context.mainComponent;
|
|
30235
|
+
this.disposeWithMe(theme.currentTheme$.subscribe(() => {
|
|
30236
|
+
this._shade = theme.getColorFromTheme("gray.200");
|
|
30237
|
+
documents.makeDirty(true);
|
|
30238
|
+
}));
|
|
30239
|
+
this.disposeWithMe(this._events.hoverCustomRanges$.subscribe((ranges) => {
|
|
30240
|
+
this._hovered = new Set(ranges.filter(({ range }) => range.rangeType === CustomRangeType.FIELD).map(({ range, segmentId, segmentPageIndex }) => `${segmentId ?? ""}:${segmentPageIndex}:${range.rangeId}`));
|
|
30241
|
+
documents.makeDirty(true);
|
|
30242
|
+
}));
|
|
30243
|
+
this.disposeWithMe(this._selections.textSelection$.subscribe(({ unitId }) => {
|
|
30244
|
+
if (unitId === this._context.unitId) documents.makeDirty(true);
|
|
30245
|
+
}));
|
|
30246
|
+
this.disposeWithMe(this._instances.focused$.subscribe(() => documents.makeDirty(true)));
|
|
30247
|
+
this.disposeWithMe(documents.getSkeleton().getViewModel().editAreaChange$.subscribe(() => documents.makeDirty(true)));
|
|
30248
|
+
this.disposeWithMe(documents.pageRender$.subscribe((config) => this._drawFields(config)));
|
|
30249
|
+
}
|
|
30250
|
+
_drawFields({ page, pageLeft, pageTop, ctx }) {
|
|
30251
|
+
var _this$_instances$getF;
|
|
30252
|
+
if (((_this$_instances$getF = this._instances.getFocusedUnit()) === null || _this$_instances$getF === void 0 ? void 0 : _this$_instances$getF.getUnitId()) !== this._context.unitId) return;
|
|
30253
|
+
const active = this._getActiveFields();
|
|
30254
|
+
if (!active.size) return;
|
|
30255
|
+
const documents = this._context.mainComponent;
|
|
30256
|
+
const skeleton = documents.getSkeleton();
|
|
30257
|
+
const pageIndex = skeleton.getSkeletonData().pages.indexOf(page);
|
|
30258
|
+
const { docsLeft, docsTop } = documents.getOffsetConfig();
|
|
30259
|
+
const area = skeleton.getViewModel().getEditArea();
|
|
30260
|
+
const snapshot = this._context.unit.getSnapshot();
|
|
30261
|
+
const activeSegments = area === DocumentEditArea.HEADER ? snapshot.headers : snapshot.footers;
|
|
30262
|
+
ctx.save();
|
|
30263
|
+
ctx.beginPath();
|
|
30264
|
+
ctx.rect(pageLeft, pageTop, page.pageWidth, page.pageHeight);
|
|
30265
|
+
ctx.clip();
|
|
30266
|
+
ctx.fillStyle = this._shade;
|
|
30267
|
+
ctx.globalAlpha *= .45;
|
|
30268
|
+
for (const { customRange: field, segmentId, segmentPageIndex, rects } of this._events.getCustomRangeBounds()) {
|
|
30269
|
+
if (field.rangeType !== CustomRangeType.FIELD) continue;
|
|
30270
|
+
if (segmentId) {
|
|
30271
|
+
if (area === DocumentEditArea.BODY || segmentPageIndex !== pageIndex || !(activeSegments === null || activeSegments === void 0 ? void 0 : activeSegments[segmentId])) continue;
|
|
30272
|
+
} else if (area !== DocumentEditArea.BODY) continue;
|
|
30273
|
+
if (!active.has(`${segmentId ?? ""}:${segmentPageIndex}:${field.rangeId}`)) continue;
|
|
30274
|
+
for (const rect of rects) ctx.fillRect(rect.left - docsLeft, rect.top - docsTop, rect.right - rect.left, rect.bottom - rect.top);
|
|
30275
|
+
}
|
|
30276
|
+
ctx.restore();
|
|
30277
|
+
}
|
|
30278
|
+
_getActiveFields() {
|
|
30279
|
+
const active = new Set(this._hovered);
|
|
30280
|
+
const selections = this._selections.getTextRanges({
|
|
30281
|
+
unitId: this._context.unitId,
|
|
30282
|
+
subUnitId: this._context.unitId
|
|
30283
|
+
}) ?? [];
|
|
30284
|
+
for (const selection of selections) {
|
|
30285
|
+
var _this$_context$unit$g;
|
|
30286
|
+
const segmentId = selection.segmentId ?? "";
|
|
30287
|
+
const fields = ((_this$_context$unit$g = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.getBody()) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.customRanges) ?? [];
|
|
30288
|
+
for (const field of fields) if (field.rangeType === CustomRangeType.FIELD && selection.startOffset <= field.endIndex && selection.endOffset > field.startIndex) active.add(`${segmentId}:${segmentId ? selection.segmentPage : -1}:${field.rangeId}`);
|
|
30289
|
+
}
|
|
30290
|
+
return active;
|
|
30291
|
+
}
|
|
30292
|
+
};
|
|
30293
|
+
DocFieldRenderController = __decorate([
|
|
30294
|
+
__decorateParam(1, Inject(DocEventManagerService)),
|
|
30295
|
+
__decorateParam(2, Inject(DocSelectionManagerService)),
|
|
30296
|
+
__decorateParam(3, Inject(ThemeService)),
|
|
30297
|
+
__decorateParam(4, IUniverInstanceService)
|
|
30298
|
+
], DocFieldRenderController);
|
|
30299
|
+
|
|
29427
30300
|
//#endregion
|
|
29428
30301
|
//#region src/controllers/render-controllers/doc-selection-render.controller.ts
|
|
29429
30302
|
let DocSelectionRenderController = class DocSelectionRenderController extends Disposable {
|
|
@@ -29748,6 +30621,32 @@ const CloseHeaderFooterShortcut = {
|
|
|
29748
30621
|
preconditions: whenDocAndEditorFocused,
|
|
29749
30622
|
binding: KeyCode.ESC
|
|
29750
30623
|
};
|
|
30624
|
+
const DeleteWordLeftShortcut = {
|
|
30625
|
+
id: DeleteLeftCommand.id,
|
|
30626
|
+
preconditions: whenTextEditorFocused,
|
|
30627
|
+
binding: KeyCode.BACKSPACE | MetaKeys.CTRL_COMMAND,
|
|
30628
|
+
mac: KeyCode.BACKSPACE | MetaKeys.ALT,
|
|
30629
|
+
staticParameters: { granularity: "word" }
|
|
30630
|
+
};
|
|
30631
|
+
const DeleteWordRightShortcut = {
|
|
30632
|
+
id: DeleteRightCommand.id,
|
|
30633
|
+
preconditions: whenTextEditorFocused,
|
|
30634
|
+
mac: KeyCode.DELETE | MetaKeys.ALT,
|
|
30635
|
+
staticParameters: { granularity: "word" }
|
|
30636
|
+
};
|
|
30637
|
+
const DeleteLineStartShortcut = {
|
|
30638
|
+
id: DeleteLeftCommand.id,
|
|
30639
|
+
preconditions: whenTextEditorFocused,
|
|
30640
|
+
mac: KeyCode.BACKSPACE | MetaKeys.CTRL_COMMAND,
|
|
30641
|
+
staticParameters: { granularity: "line" }
|
|
30642
|
+
};
|
|
30643
|
+
const DeleteLineEndShortcut = {
|
|
30644
|
+
id: DeleteRightCommand.id,
|
|
30645
|
+
preconditions: whenTextEditorFocused,
|
|
30646
|
+
binding: KeyCode.DELETE | MetaKeys.CTRL_COMMAND,
|
|
30647
|
+
mac: KeyCode.DELETE | MetaKeys.MAC_CTRL,
|
|
30648
|
+
staticParameters: { granularity: "line" }
|
|
30649
|
+
};
|
|
29751
30650
|
|
|
29752
30651
|
//#endregion
|
|
29753
30652
|
//#region src/shortcuts/cursor.shortcut.ts
|
|
@@ -29758,7 +30657,7 @@ function moveCursorShortcut(direction, granularity, binding, mac = binding, win
|
|
|
29758
30657
|
mac,
|
|
29759
30658
|
win,
|
|
29760
30659
|
linux,
|
|
29761
|
-
preconditions:
|
|
30660
|
+
preconditions: whenTextEditorFocused,
|
|
29762
30661
|
staticParameters: {
|
|
29763
30662
|
direction,
|
|
29764
30663
|
granularity
|
|
@@ -29772,7 +30671,7 @@ function moveSelectionShortcut(direction, granularity, binding, mac = binding, w
|
|
|
29772
30671
|
mac,
|
|
29773
30672
|
win,
|
|
29774
30673
|
linux,
|
|
29775
|
-
preconditions:
|
|
30674
|
+
preconditions: whenTextEditorFocused,
|
|
29776
30675
|
staticParameters: {
|
|
29777
30676
|
direction,
|
|
29778
30677
|
granularity
|
|
@@ -30035,6 +30934,10 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
|
|
|
30035
30934
|
MoveSelectionWordRightShortcut,
|
|
30036
30935
|
SelectAllShortcut,
|
|
30037
30936
|
DeleteLeftShortcut,
|
|
30937
|
+
DeleteWordLeftShortcut,
|
|
30938
|
+
DeleteWordRightShortcut,
|
|
30939
|
+
DeleteLineStartShortcut,
|
|
30940
|
+
DeleteLineEndShortcut,
|
|
30038
30941
|
DeleteRightShortcut,
|
|
30039
30942
|
CloseHeaderFooterShortcut,
|
|
30040
30943
|
BreakLineShortcut,
|
|
@@ -30111,10 +31014,12 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
|
|
|
30111
31014
|
_initRenderModules() {
|
|
30112
31015
|
[
|
|
30113
31016
|
[DocEventManagerService],
|
|
31017
|
+
[DocFieldRenderController],
|
|
30114
31018
|
[DocFloatMenuService],
|
|
30115
31019
|
[DocPasteOptionsRenderController],
|
|
30116
31020
|
[DocParagraphMenuService],
|
|
30117
31021
|
[DocHeaderFooterController],
|
|
31022
|
+
[DocHeaderFooterRibbonController],
|
|
30118
31023
|
[DocResizeRenderController],
|
|
30119
31024
|
[DocParagraphPlaceholderRenderController],
|
|
30120
31025
|
[DocContextMenuRenderController],
|