@a3s-lab/office 0.45.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ import { Fragment as external_react_Fragment, forwardRef, useCallback, useEffect
6
6
  import { Extension, createNodeFromContent } from "@tiptap/core";
7
7
  import { NodeSelection, Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
8
8
  import { Decoration, DecorationSet } from "@tiptap/pm/view";
9
- import { AArrowDown, AArrowUp, ALargeSmall, AlignCenter, AlignJustify, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, BetweenHorizontalEnd, BetweenHorizontalStart, BetweenVerticalEnd, BetweenVerticalStart, Bold, BookMarked, BookOpen, Bookmark, CaseUpper, Check, CheckCheck, CheckCircle2, ChevronDown, ChevronRight, ChevronUp, ClipboardCopy, ClipboardPaste, Cloud, Columns3, Eraser, Eye, FileCheck2, FileDiff, FilePlus2, FileStack, FileText, FileUp, FlipHorizontal2, FlipVertical2, GitCompareArrows, Globe2, Grid2X2, Hash, Highlighter, Image, IndentDecrease, IndentIncrease, Italic, Languages, Link2, List, ListChecks, ListOrdered, ListTree, MessageSquarePlus, MessageSquareReply, MessagesSquare, MoveVertical, Paintbrush, Palette, PanelBottom, PanelBottomOpen, PanelLeftOpen, PanelTop, PanelTopOpen, Pilcrow, PilcrowLeft, PilcrowRight, Plus, Quote, Redo2, RefreshCw, Replace, ReplaceAll, RotateCcw, RotateCw, Rows3, Ruler, Scan, Search, Settings2, Square, StretchHorizontal, Strikethrough, Subscript, Superscript, Table2, TableCellsMerge, TableCellsSplit, TableProperties, Tags, TextWrap, Trash2, TriangleAlert, Type, Underline, Undo2, Unlink, Unlink2, X, XCircle, ZoomIn, ZoomOut } from "lucide-react";
9
+ import { AArrowDown, AArrowUp, ALargeSmall, AlignCenter, AlignJustify, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, BetweenHorizontalEnd, BetweenHorizontalStart, BetweenVerticalEnd, BetweenVerticalStart, Bold, BookMarked, BookOpen, Bookmark, CaseUpper, Check, CheckCheck, CheckCircle2, ChevronDown, ChevronRight, ChevronUp, ClipboardCopy, ClipboardPaste, Cloud, Columns3, Eraser, Eye, FileCheck2, FileDiff, FilePlus2, FileStack, FileText, FileUp, FlipHorizontal2, FlipVertical2, GitCompareArrows, Globe2, Grid2X2, Hash, Highlighter, Image, IndentDecrease, IndentIncrease, Italic, Languages, Link2, List, ListChecks, ListOrdered, ListTree, MessageSquarePlus, MessageSquareReply, MessagesSquare, Move, MoveVertical, Paintbrush, Palette, PanelBottom, PanelBottomOpen, PanelLeftOpen, PanelTop, PanelTopOpen, Pilcrow, PilcrowLeft, PilcrowRight, Plus, Quote, Redo2, RefreshCw, Replace, ReplaceAll, RotateCcw, RotateCw, Rows3, Ruler, Scan, Search, Settings2, Square, SquareDashedMousePointer, StretchHorizontal, Strikethrough, Subscript, Superscript, Table2, TableCellsMerge, TableCellsSplit, TableProperties, Tags, TextCursorInput, TextWrap, Trash2, TriangleAlert, Type, Underline, Undo2, Unlink, Unlink2, X, XCircle, ZoomIn, ZoomOut } from "lucide-react";
10
10
  import { Fragment as model_Fragment, Node as model_Node } from "@tiptap/pm/model";
11
11
  import extension_color from "@tiptap/extension-color";
12
12
  import { TableKit } from "@tiptap/extension-table";
@@ -16,7 +16,7 @@ import starter_kit from "@tiptap/starter-kit";
16
16
  import { BubbleMenu } from "@tiptap/react/menus";
17
17
  import { TableMap, isInTable, selectedRect } from "@tiptap/pm/tables";
18
18
  import { closeHistory } from "@tiptap/pm/history";
19
- import { documentTableSizing, transferChangedDocumentTextStatistics, documentPageBordersVisible, documentUnderlineStyle, DOCUMENT_PAGE_BORDER_EDGES, documentTableRowOptions, normalizeDocumentColumns, clampDocumentMargin, materializeLazyDocumentEditorRoot, documentKerningThresholdPoints, selectedDocumentIndexOptions, nextDocumentTabAlignment, DOCUMENT_BOOKMARK_DUPLICATE_MESSAGE, normalizedTabPosition, documentCitationCount, resolveDocumentPageBorders, documentLazyHtmlChunkFragment, DocumentFontFamily, normalizeDocumentHiddenText, documentLegacyTextEffectsConflict, DOCUMENT_CHUNK_VISIBLE_IDS_META, selectedDocumentIndexDraft, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, retainAnchoredDocumentComments, DocumentTableRowIdentity, work_document_page_margins_twipsToMillimeters, DEFAULT_DOCUMENT_TABLE_CELL_FORMAT, resolveWorkDocumentEditorInput, defaultDocumentImageTransform, documentOpenTypeCssProperties, documentBulletListStyle, documentCharacterPositionPoints, collectDocumentTextLayoutParagraphs, readOfficeDocumentCollaboration as readWorkOfficeDocumentCollaboration, normalizeDocumentCharacterScalePercent, DOCUMENT_PARAGRAPH_FORMAT_ATTRIBUTES, documentOrderedListState, normalizeDocumentPageChrome, documentTextStatistics, documentPageMarginsForLayout, invalidateDocumentLazyHtmlProjection, documentTableCellFormat, normalizeDocumentImageTransform, normalizeDocumentPageGeometry, documentImageProperties, normalizeDocumentImageLayer, isValidDocumentCitationTag, sanitizeDocumentPageChromeHtml, pageTwipsToMillimeters, normalizeDocumentPageBorders, importWorkDocumentFile, DocumentParagraphFormatting, documentModelHasTrustedInitialIntegrityFeatures, normalizeDocumentHtml, documentInitialSectionLayout, activeDocumentSection, documentParagraphDirection, documentParagraphPagination, normalizeDocumentOpenTypeFeatures, isDocumentCharacterFormatMark, documentModelUsesWindowing, documentPageChromeLegacyFields, documentChunkMountedIds, collectDocumentCommentAnchors, documentTextCaseKeyboardShortcuts, DocumentTextStyle, canChangeDocumentIndent, patchDocumentOpenTypeFeatures, normalizeDocumentOpenTypeNumberForm, parseDocumentOpenTypeFeatures, documentCharacterSpacingPoints, documentKerningIsEffective, DocumentSuperscript, documentSectionById, activeDocumentBookmark, DocumentEquation, documentLazyHtmlProjectionFingerprint, documentLazyHtmlProjection, normalizeDocumentParagraphIndent, updateDocumentGutterPosition, DocumentStrike, mountWorkLiveDocumentCapture, registerDocumentPageSurfaceGeometry, documentHiddenTextKeyboardShortcut, documentHasIndex, syncDocumentContentFromHtml, documentLegacyTextEffectsCss, editorDocumentCaptionTargets, resolveDocumentPageChrome, documentImageLayoutOptions, MAX_DOCUMENT_NUMBERING_START, resolveDocumentPageSize, normalizeDocumentOpenTypeNumberSpacing, editorDocumentBookmarkReferenceTargets, serializeWorkDocumentNode, DOCUMENT_CHUNK_PAGINATION_META, documentModelForContent, createOfficeDocumentCollaborationBinding as createWorkOfficeDocumentCollaborationBinding, documentLegacyTextEffectsFromTextStyleAttributes, normalizeDocumentEmphasisMark, selectedDocumentChunkId, documentCommentViews, documentParagraphSpacing, normalizeDocumentTabStops, patchDocumentLazyHtmlProjection, normalizeDocumentTextCase, documentUnderlineColor, documentBookmarkNameExists, collectDocumentChanges, DocumentImage, selectedDocumentTableOfContentsOptions, resolveDocumentPageMargins, updateDocumentPageMarginMode, serializeDocumentParagraphFormatting, canSetDocumentTableRowRepeatHeader, isDocumentOpenTypeFeaturePatch, normalizeDocumentCharacterSpacingTwips, DocumentCharacterFormatting, millimetersToPixels as work_document_layout_millimetersToPixels, DOCUMENT_PARAGRAPH_CHANGE_ATTRIBUTES, serializeDocumentCharacterFormatting, DOCUMENT_CHUNK_HYDRATION_META, documentTabLeaderLabel, createSchemaDerivedWorkDocumentModel, updateDocumentCustomPageMillimeters, DocumentUnderline, documentCommentDraftRange, documentParagraphTabStops, documentTableHorizontalAlignment, documentUnderlineKeyboardShortcuts, documentParagraphIndent, DocumentScriptFontFormatting, canInsertDocumentComment, resolveAllDocumentChanges, serializeDocumentOpenTypeFeatures, documentHasTableOfContents, documentTextLayoutBatches, normalizeDocumentImageWrapSide, updateDocumentPageOrientation, documentCitationStyleDetails, validateDocumentBookmarkName, setCustomDocumentColumns, updateDocumentPageMarginMillimeters, normalizeDocumentCharacterPositionHalfPoints, documentCitationStyle, documentTransactionsOnlyHydrateChunks, normalizeDocumentKerningThresholdHalfPoints, forgetSourceBlob as forgetWorkSourceBlob, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DOCUMENT_TABLE_STYLE_OPTIONS, updateDocumentColumnWidth, updateDocumentPaperSizePreset, documentPageMetrics, documentStrikeStyle, DocumentHighlight, createDocumentBibliography, DocumentSubscript, normalizeDocumentOpenTypeLigatures, selectedDocumentIndexEntry, updateDocumentPageChromeVariant, updateDocumentMirrorMargins, activeDocumentTableStyle, measureDocumentLayoutBlocksIncrementally, documentWordLineHeightFactor, normalizeDocumentLegacyTextEffect, createWorkDocumentExtensions } from "./4174.js";
19
+ import { documentTableSizing, transferChangedDocumentTextStatistics, documentPageBordersVisible, documentUnderlineStyle, DOCUMENT_PAGE_BORDER_EDGES, documentTableRowOptions, normalizeDocumentColumns, clampDocumentMargin, materializeLazyDocumentEditorRoot, documentKerningThresholdPoints, selectedDocumentIndexOptions, nextDocumentTabAlignment, DOCUMENT_BOOKMARK_DUPLICATE_MESSAGE, normalizedTabPosition, documentTextBoxProperties, documentCitationCount, resolveDocumentPageBorders, documentLazyHtmlChunkFragment, DocumentFontFamily, normalizeDocumentHiddenText, documentLegacyTextEffectsConflict, DOCUMENT_CHUNK_VISIBLE_IDS_META, selectedDocumentIndexDraft, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, retainAnchoredDocumentComments, DocumentTableRowIdentity, work_document_page_margins_twipsToMillimeters, DEFAULT_DOCUMENT_TABLE_CELL_FORMAT, resolveWorkDocumentEditorInput, defaultDocumentImageTransform, documentOpenTypeCssProperties, documentBulletListStyle, documentCharacterPositionPoints, collectDocumentTextLayoutParagraphs, readOfficeDocumentCollaboration as readWorkOfficeDocumentCollaboration, normalizeDocumentCharacterScalePercent, DOCUMENT_PARAGRAPH_FORMAT_ATTRIBUTES, documentOrderedListState, normalizeDocumentPageChrome, documentTextStatistics, documentPageMarginsForLayout, invalidateDocumentLazyHtmlProjection, documentTableCellFormat, normalizeDocumentImageTransform, normalizeDocumentPageGeometry, documentImageProperties, normalizeDocumentImageLayer, isValidDocumentCitationTag, sanitizeDocumentPageChromeHtml, pageTwipsToMillimeters, normalizeDocumentPageBorders, importWorkDocumentFile, DocumentParagraphFormatting, documentModelHasTrustedInitialIntegrityFeatures, normalizeDocumentHtml, documentInitialSectionLayout, activeDocumentSection, documentParagraphDirection, documentParagraphPagination, normalizeDocumentOpenTypeFeatures, isDocumentCharacterFormatMark, documentModelUsesWindowing, documentPageChromeLegacyFields, documentChunkMountedIds, collectDocumentCommentAnchors, documentTextCaseKeyboardShortcuts, DocumentTextStyle, canChangeDocumentIndent, patchDocumentOpenTypeFeatures, normalizeDocumentOpenTypeNumberForm, parseDocumentOpenTypeFeatures, documentCharacterSpacingPoints, documentKerningIsEffective, DocumentSuperscript, DOCUMENT_TEXT_BOX_LIMITS, documentSectionById, activeDocumentBookmark, DocumentEquation, documentLazyHtmlProjectionFingerprint, documentLazyHtmlProjection, normalizeDocumentParagraphIndent, updateDocumentGutterPosition, DocumentStrike, mountWorkLiveDocumentCapture, registerDocumentPageSurfaceGeometry, documentHiddenTextKeyboardShortcut, documentHasIndex, syncDocumentContentFromHtml, documentLegacyTextEffectsCss, editorDocumentCaptionTargets, resolveDocumentPageChrome, documentImageLayoutOptions, MAX_DOCUMENT_NUMBERING_START, resolveDocumentPageSize, normalizeDocumentOpenTypeNumberSpacing, editorDocumentBookmarkReferenceTargets, serializeWorkDocumentNode, DOCUMENT_CHUNK_PAGINATION_META, documentModelForContent, createOfficeDocumentCollaborationBinding as createWorkOfficeDocumentCollaborationBinding, documentLegacyTextEffectsFromTextStyleAttributes, normalizeDocumentEmphasisMark, selectedDocumentChunkId, documentCommentViews, documentParagraphSpacing, normalizeDocumentTabStops, patchDocumentLazyHtmlProjection, normalizeDocumentTextCase, documentUnderlineColor, documentBookmarkNameExists, collectDocumentChanges, DocumentImage, selectedDocumentTableOfContentsOptions, resolveDocumentPageMargins, updateDocumentPageMarginMode, serializeDocumentParagraphFormatting, canSetDocumentTableRowRepeatHeader, isDocumentOpenTypeFeaturePatch, normalizeDocumentCharacterSpacingTwips, DocumentCharacterFormatting, millimetersToPixels as work_document_layout_millimetersToPixels, DOCUMENT_PARAGRAPH_CHANGE_ATTRIBUTES, serializeDocumentCharacterFormatting, DOCUMENT_CHUNK_HYDRATION_META, documentTabLeaderLabel, createSchemaDerivedWorkDocumentModel, updateDocumentCustomPageMillimeters, DocumentUnderline, documentCommentDraftRange, documentParagraphTabStops, documentTableHorizontalAlignment, documentUnderlineKeyboardShortcuts, documentParagraphIndent, DocumentScriptFontFormatting, canInsertDocumentComment, resolveAllDocumentChanges, serializeDocumentOpenTypeFeatures, documentHasTableOfContents, documentTextLayoutBatches, normalizeDocumentImageWrapSide, updateDocumentPageOrientation, documentCitationStyleDetails, validateDocumentBookmarkName, setCustomDocumentColumns, updateDocumentPageMarginMillimeters, normalizeDocumentCharacterPositionHalfPoints, documentCitationStyle, documentTransactionsOnlyHydrateChunks, normalizeDocumentKerningThresholdHalfPoints, forgetSourceBlob as forgetWorkSourceBlob, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DOCUMENT_TABLE_STYLE_OPTIONS, updateDocumentColumnWidth, updateDocumentPaperSizePreset, documentPageMetrics, documentStrikeStyle, DocumentHighlight, createDocumentBibliography, DocumentSubscript, normalizeDocumentOpenTypeLigatures, selectedDocumentIndexEntry, updateDocumentPageChromeVariant, updateDocumentMirrorMargins, DOCUMENT_TEXT_BOX_DEFAULTS, activeDocumentTableStyle, measureDocumentLayoutBlocksIncrementally, documentWordLineHeightFactor, normalizeDocumentLegacyTextEffect, createWorkDocumentExtensions } from "./4174.js";
20
20
  import { useOfficeTaskPaneEscape, OfficeCheckbox, useOfficeDialog, useOfficeTaskPaneModal, CommittedOfficeNumberField, createOfficeKernelClient, CollectionState, OfficeNumberField } from "./0~7831.js";
21
21
  import { moveOfficeMenuFocus, office_text_field_OfficeTextArea, Popover, officeOverlayPortalRoot, Dialog, button_Button, useOfficePublishPresenceLocation, OfficeTiptapPresenceLayer, icon_button_IconButton, office_text_field_OfficeTextField, useDialogFocusScope, useOfficeEditorWheelZoom, office_text_field_OfficeFileInput } from "./0~8136.js";
22
22
  import { WorkOfficePreviewBar, isWorkspaceContextMenuKeyboardEvent, Tabs, WorkOfficeZoomControls, WorkOfficeStatusBar, WorkOfficeRibbon, workspaceContextMenuPosition, OfficeSelect, WorkspaceContextMenu, WorkOfficeRibbonGroup, WorkOfficeRibbonButton } from "./0~9073.js";
@@ -6843,6 +6843,11 @@ const documentPictureRibbonTab = {
6843
6843
  label: '图片',
6844
6844
  contextual: true
6845
6845
  };
6846
+ const documentTextBoxRibbonTab = {
6847
+ id: 'textBox',
6848
+ label: '文本框',
6849
+ contextual: true
6850
+ };
6846
6851
  const documentTableRibbonTabs = [
6847
6852
  {
6848
6853
  id: 'tableDesign',
@@ -7397,6 +7402,15 @@ const documentCommandCatalog = {
7397
7402
  ]
7398
7403
  }
7399
7404
  },
7405
+ insertTextBox: {
7406
+ id: 'insert.textBox',
7407
+ label: '插入文本框',
7408
+ location: {
7409
+ area: 'ribbon',
7410
+ tab: 'insert',
7411
+ group: 'text'
7412
+ }
7413
+ },
7400
7414
  hyperlink: {
7401
7415
  id: 'insert.hyperlink',
7402
7416
  label: '添加链接',
@@ -15616,6 +15630,370 @@ function RibbonButton({ label, visibleLabel, active = false, disabled = false, o
15616
15630
  });
15617
15631
  }
15618
15632
  const document_table_ribbon_RibbonGroup = WorkOfficeRibbonGroup;
15633
+ const document_text_box_ribbon_layoutOptions = [
15634
+ {
15635
+ value: 'inline',
15636
+ label: '嵌入文字',
15637
+ icon: Rows3
15638
+ },
15639
+ {
15640
+ value: 'floating',
15641
+ label: '浮于文字上方',
15642
+ icon: SquareDashedMousePointer
15643
+ }
15644
+ ];
15645
+ const document_text_box_ribbon_horizontalReferenceOptions = [
15646
+ {
15647
+ value: 'column',
15648
+ label: '栏'
15649
+ },
15650
+ {
15651
+ value: 'margin',
15652
+ label: '页边距'
15653
+ },
15654
+ {
15655
+ value: 'page',
15656
+ label: '页面'
15657
+ }
15658
+ ];
15659
+ const document_text_box_ribbon_verticalReferenceOptions = [
15660
+ {
15661
+ value: 'paragraph',
15662
+ label: '段落'
15663
+ },
15664
+ {
15665
+ value: 'margin',
15666
+ label: '页边距'
15667
+ },
15668
+ {
15669
+ value: 'page',
15670
+ label: '页面'
15671
+ }
15672
+ ];
15673
+ const verticalAlignOptions = [
15674
+ {
15675
+ value: 'top',
15676
+ label: '顶端',
15677
+ icon: AlignVerticalJustifyStart
15678
+ },
15679
+ {
15680
+ value: 'center',
15681
+ label: '居中',
15682
+ icon: AlignVerticalJustifyCenter
15683
+ },
15684
+ {
15685
+ value: 'bottom',
15686
+ label: '底端',
15687
+ icon: AlignVerticalJustifyEnd
15688
+ }
15689
+ ];
15690
+ const borderWidthOptions = [
15691
+ {
15692
+ value: '0',
15693
+ label: '无边框'
15694
+ },
15695
+ {
15696
+ value: '0.35',
15697
+ label: '细(0.35 mm)'
15698
+ },
15699
+ {
15700
+ value: '0.7',
15701
+ label: '中(0.7 mm)'
15702
+ },
15703
+ {
15704
+ value: '1.4',
15705
+ label: '粗(1.4 mm)'
15706
+ }
15707
+ ];
15708
+ function DocumentTextBoxRibbon({ editor }) {
15709
+ const properties = documentTextBoxProperties(editor);
15710
+ const selected = editor.isActive('documentTextBox');
15711
+ const update = (value)=>{
15712
+ if (!selected) return;
15713
+ editor.commands.setDocumentTextBoxProperties(value, {
15714
+ restoreFocus: false
15715
+ });
15716
+ };
15717
+ const updateLayout = (layout)=>{
15718
+ update({
15719
+ layout,
15720
+ ...'floating' === layout ? {
15721
+ horizontalOffset: properties.horizontalOffset ?? 0,
15722
+ verticalOffset: properties.verticalOffset ?? 0
15723
+ } : {}
15724
+ });
15725
+ };
15726
+ return /*#__PURE__*/ jsxs(Fragment, {
15727
+ children: [
15728
+ /*#__PURE__*/ jsx(WorkOfficeRibbonGroup, {
15729
+ label: "布局",
15730
+ priority: "high",
15731
+ children: document_text_box_ribbon_layoutOptions.map((option)=>{
15732
+ const Icon = option.icon;
15733
+ return /*#__PURE__*/ jsx(TextBoxButton, {
15734
+ label: option.label,
15735
+ active: selected && properties.layout === option.value,
15736
+ disabled: !selected,
15737
+ onClick: ()=>updateLayout(option.value),
15738
+ children: /*#__PURE__*/ jsx(Icon, {
15739
+ size: 18
15740
+ })
15741
+ }, option.value);
15742
+ })
15743
+ }),
15744
+ /*#__PURE__*/ jsxs(WorkOfficeRibbonGroup, {
15745
+ label: "大小",
15746
+ children: [
15747
+ /*#__PURE__*/ jsxs("div", {
15748
+ className: "work-office-field work-document-text-box-size-field",
15749
+ children: [
15750
+ /*#__PURE__*/ jsx("span", {
15751
+ children: "宽度(毫米)"
15752
+ }),
15753
+ /*#__PURE__*/ jsx(CommittedOfficeNumberField, {
15754
+ ariaLabel: "文本框宽度(毫米)",
15755
+ value: properties.width,
15756
+ min: DOCUMENT_TEXT_BOX_LIMITS.width.min,
15757
+ max: DOCUMENT_TEXT_BOX_LIMITS.width.max,
15758
+ step: 0.1,
15759
+ disabled: !selected,
15760
+ normalizeValue: (value)=>normalizeTextBoxNumber(value, DOCUMENT_TEXT_BOX_LIMITS.width.min, DOCUMENT_TEXT_BOX_LIMITS.width.max),
15761
+ onValueCommit: (width)=>update({
15762
+ width
15763
+ })
15764
+ })
15765
+ ]
15766
+ }),
15767
+ /*#__PURE__*/ jsxs("div", {
15768
+ className: "work-office-field work-document-text-box-size-field",
15769
+ children: [
15770
+ /*#__PURE__*/ jsx("span", {
15771
+ children: "高度(毫米)"
15772
+ }),
15773
+ /*#__PURE__*/ jsx(CommittedOfficeNumberField, {
15774
+ ariaLabel: "文本框高度(毫米)",
15775
+ value: properties.height,
15776
+ min: DOCUMENT_TEXT_BOX_LIMITS.height.min,
15777
+ max: DOCUMENT_TEXT_BOX_LIMITS.height.max,
15778
+ step: 0.1,
15779
+ disabled: !selected,
15780
+ normalizeValue: (value)=>normalizeTextBoxNumber(value, DOCUMENT_TEXT_BOX_LIMITS.height.min, DOCUMENT_TEXT_BOX_LIMITS.height.max),
15781
+ onValueCommit: (height)=>update({
15782
+ height
15783
+ })
15784
+ })
15785
+ ]
15786
+ })
15787
+ ]
15788
+ }),
15789
+ /*#__PURE__*/ jsxs(WorkOfficeRibbonGroup, {
15790
+ label: "位置",
15791
+ children: [
15792
+ /*#__PURE__*/ jsxs("div", {
15793
+ className: "work-office-field work-document-text-box-position-field",
15794
+ children: [
15795
+ /*#__PURE__*/ jsx("span", {
15796
+ children: "水平相对于"
15797
+ }),
15798
+ /*#__PURE__*/ jsx(OfficeSelect, {
15799
+ ariaLabel: "文本框水平相对于",
15800
+ value: properties.horizontalReference,
15801
+ options: document_text_box_ribbon_horizontalReferenceOptions,
15802
+ disabled: !selected || 'floating' !== properties.layout,
15803
+ onValueChange: (horizontalReference)=>update({
15804
+ horizontalReference
15805
+ })
15806
+ })
15807
+ ]
15808
+ }),
15809
+ /*#__PURE__*/ jsxs("div", {
15810
+ className: "work-office-field work-document-text-box-position-field",
15811
+ children: [
15812
+ /*#__PURE__*/ jsx("span", {
15813
+ children: "垂直相对于"
15814
+ }),
15815
+ /*#__PURE__*/ jsx(OfficeSelect, {
15816
+ ariaLabel: "文本框垂直相对于",
15817
+ value: properties.verticalReference,
15818
+ options: document_text_box_ribbon_verticalReferenceOptions,
15819
+ disabled: !selected || 'floating' !== properties.layout,
15820
+ onValueChange: (verticalReference)=>update({
15821
+ verticalReference
15822
+ })
15823
+ })
15824
+ ]
15825
+ }),
15826
+ /*#__PURE__*/ jsxs("div", {
15827
+ className: "work-office-field work-document-text-box-offset-field",
15828
+ children: [
15829
+ /*#__PURE__*/ jsx("span", {
15830
+ children: "水平偏移(毫米)"
15831
+ }),
15832
+ /*#__PURE__*/ jsx(CommittedOfficeNumberField, {
15833
+ ariaLabel: "文本框水平偏移(毫米)",
15834
+ value: properties.horizontalOffset ?? 0,
15835
+ min: DOCUMENT_TEXT_BOX_LIMITS.offset.min,
15836
+ max: DOCUMENT_TEXT_BOX_LIMITS.offset.max,
15837
+ step: 0.1,
15838
+ disabled: !selected || 'floating' !== properties.layout,
15839
+ normalizeValue: (value)=>normalizeTextBoxNumber(value, DOCUMENT_TEXT_BOX_LIMITS.offset.min, DOCUMENT_TEXT_BOX_LIMITS.offset.max),
15840
+ onValueCommit: (horizontalOffset)=>update({
15841
+ horizontalOffset
15842
+ })
15843
+ })
15844
+ ]
15845
+ }),
15846
+ /*#__PURE__*/ jsxs("div", {
15847
+ className: "work-office-field work-document-text-box-offset-field",
15848
+ children: [
15849
+ /*#__PURE__*/ jsx("span", {
15850
+ children: "垂直偏移(毫米)"
15851
+ }),
15852
+ /*#__PURE__*/ jsx(CommittedOfficeNumberField, {
15853
+ ariaLabel: "文本框垂直偏移(毫米)",
15854
+ value: properties.verticalOffset ?? 0,
15855
+ min: DOCUMENT_TEXT_BOX_LIMITS.offset.min,
15856
+ max: DOCUMENT_TEXT_BOX_LIMITS.offset.max,
15857
+ step: 0.1,
15858
+ disabled: !selected || 'floating' !== properties.layout,
15859
+ normalizeValue: (value)=>normalizeTextBoxNumber(value, DOCUMENT_TEXT_BOX_LIMITS.offset.min, DOCUMENT_TEXT_BOX_LIMITS.offset.max),
15860
+ onValueCommit: (verticalOffset)=>update({
15861
+ verticalOffset
15862
+ })
15863
+ })
15864
+ ]
15865
+ })
15866
+ ]
15867
+ }),
15868
+ /*#__PURE__*/ jsx(WorkOfficeRibbonGroup, {
15869
+ label: "文本对齐",
15870
+ children: verticalAlignOptions.map((option)=>{
15871
+ const Icon = option.icon;
15872
+ return /*#__PURE__*/ jsx(TextBoxButton, {
15873
+ label: option.label,
15874
+ active: selected && properties.verticalAlign === option.value,
15875
+ disabled: !selected,
15876
+ onClick: ()=>update({
15877
+ verticalAlign: option.value
15878
+ }),
15879
+ children: /*#__PURE__*/ jsx(Icon, {
15880
+ size: 18
15881
+ })
15882
+ }, option.value);
15883
+ })
15884
+ }),
15885
+ /*#__PURE__*/ jsxs(WorkOfficeRibbonGroup, {
15886
+ label: "填充和轮廓",
15887
+ children: [
15888
+ /*#__PURE__*/ jsx(OfficeColorPicker, {
15889
+ ariaLabel: "文本框填充颜色",
15890
+ triggerLabel: "填充",
15891
+ value: properties.fill,
15892
+ disabled: !selected,
15893
+ resetAction: {
15894
+ kind: 'automatic',
15895
+ label: '无填充',
15896
+ onSelect: ()=>update({
15897
+ fill: 'transparent'
15898
+ })
15899
+ },
15900
+ onValueChange: (fill)=>update({
15901
+ fill
15902
+ })
15903
+ }),
15904
+ /*#__PURE__*/ jsx(OfficeColorPicker, {
15905
+ ariaLabel: "文本框边框颜色",
15906
+ triggerLabel: "边框",
15907
+ value: 'none' === properties.borderColor ? '#ffffff' : properties.borderColor,
15908
+ disabled: !selected,
15909
+ resetAction: {
15910
+ kind: 'none',
15911
+ label: '无轮廓',
15912
+ onSelect: ()=>update({
15913
+ borderColor: 'none',
15914
+ borderWidth: 0
15915
+ })
15916
+ },
15917
+ onValueChange: (borderColor)=>update({
15918
+ borderColor
15919
+ })
15920
+ }),
15921
+ /*#__PURE__*/ jsx(OfficeSelect, {
15922
+ ariaLabel: "文本框边框粗细",
15923
+ value: String(properties.borderWidth),
15924
+ options: borderWidthOptionsForValue(String(properties.borderWidth)),
15925
+ disabled: !selected,
15926
+ onValueChange: (value)=>update({
15927
+ borderWidth: Number(value),
15928
+ ...'0' === value ? {
15929
+ borderColor: 'none'
15930
+ } : {}
15931
+ })
15932
+ })
15933
+ ]
15934
+ }),
15935
+ /*#__PURE__*/ jsxs(WorkOfficeRibbonGroup, {
15936
+ label: "文本框",
15937
+ children: [
15938
+ /*#__PURE__*/ jsx(TextBoxButton, {
15939
+ label: "删除文本框",
15940
+ disabled: !selected,
15941
+ onClick: ()=>editor.commands.deleteDocumentTextBox(),
15942
+ children: /*#__PURE__*/ jsx(Trash2, {
15943
+ size: 18
15944
+ })
15945
+ }),
15946
+ /*#__PURE__*/ jsx(TextBoxButton, {
15947
+ label: "恢复默认样式",
15948
+ disabled: !selected,
15949
+ onClick: ()=>update({
15950
+ width: DOCUMENT_TEXT_BOX_DEFAULTS.width,
15951
+ height: DOCUMENT_TEXT_BOX_DEFAULTS.height,
15952
+ layout: DOCUMENT_TEXT_BOX_DEFAULTS.layout,
15953
+ horizontalOffset: DOCUMENT_TEXT_BOX_DEFAULTS.horizontalOffset,
15954
+ verticalOffset: DOCUMENT_TEXT_BOX_DEFAULTS.verticalOffset,
15955
+ horizontalReference: DOCUMENT_TEXT_BOX_DEFAULTS.horizontalReference,
15956
+ verticalReference: DOCUMENT_TEXT_BOX_DEFAULTS.verticalReference,
15957
+ fill: DOCUMENT_TEXT_BOX_DEFAULTS.fill,
15958
+ borderColor: DOCUMENT_TEXT_BOX_DEFAULTS.borderColor,
15959
+ borderWidth: DOCUMENT_TEXT_BOX_DEFAULTS.borderWidth,
15960
+ padding: DOCUMENT_TEXT_BOX_DEFAULTS.padding,
15961
+ verticalAlign: DOCUMENT_TEXT_BOX_DEFAULTS.verticalAlign
15962
+ }),
15963
+ children: /*#__PURE__*/ jsx(Move, {
15964
+ size: 18
15965
+ })
15966
+ })
15967
+ ]
15968
+ })
15969
+ ]
15970
+ });
15971
+ }
15972
+ function TextBoxButton({ label, active = false, disabled = false, onClick, children }) {
15973
+ return /*#__PURE__*/ jsx(WorkOfficeRibbonButton, {
15974
+ label: label,
15975
+ displayLabel: true,
15976
+ active: active,
15977
+ disabled: disabled,
15978
+ onClick: onClick,
15979
+ children: children
15980
+ });
15981
+ }
15982
+ function normalizeTextBoxNumber(value, min, max) {
15983
+ const number = Number(value);
15984
+ if (!Number.isFinite(number) || number < min || number > max) return null;
15985
+ return Number(number.toFixed(2));
15986
+ }
15987
+ function borderWidthOptionsForValue(value) {
15988
+ if (borderWidthOptions.some((option)=>option.value === value)) return borderWidthOptions;
15989
+ return [
15990
+ ...borderWidthOptions,
15991
+ {
15992
+ value,
15993
+ label: `${value} 毫米`
15994
+ }
15995
+ ];
15996
+ }
15619
15997
  function runDocumentWpsShortcut(editor, event, callbacks) {
15620
15998
  if (editor.isDestroyed) return false;
15621
15999
  const key = event.key.toLowerCase();
@@ -15738,13 +16116,14 @@ function headingLevelForShortcut(code, key) {
15738
16116
  if ('3' === value) return 3;
15739
16117
  return null;
15740
16118
  }
15741
- function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly = false, suggestionOnly = false, history, layoutOpen, layout, layoutFonts = [], navigationOpen, pageColor, showPageNumbers, showHiddenText, showRulers, spellcheckEnabled, viewMode, zoom, pageChromeEditor, pageChromeEditingPart, pageChromeShowPageNumber, onRequestImage, onPageChromeEditingPartChange, onClosePageChrome, onTogglePageChromePageNumber, onToggleLayout, onLayoutChange, onOpenLayout, onToggleNavigation, onTogglePageNumbers, onToggleHiddenText, onToggleRulers, onPageColorChange, onToggleSpellcheck, onViewModeChange, onZoomChange, onZoomFit, onInsertSection, onInsertNote, onInsertCaption, onInsertCrossReference, onOpenTableOfContents, onOpenIndexEntry, onOpenIndex, citationsOpen, citationSourceCount, onToggleCitations, onInsertField, onRefreshFields, onRefreshIndex, onRefreshTableOfContents, canInsertComment, onInsertComment, commentsOpen, commentCount, onToggleComments, trackChanges, changesOpen, changeCount, findReplaceMode, fileActions, onRibbonTabChange, onToggleTrackChanges, onToggleChanges, onOpenComparison, onDecideChange, onOpenWordCount, onOpenFindReplace }) {
16119
+ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly = false, suggestionOnly = false, history, layoutOpen, layout, layoutFonts = [], navigationOpen, pageColor, showPageNumbers, showHiddenText, showRulers, spellcheckEnabled, viewMode, zoom, pageChromeEditor, pageChromeEditingPart, pageChromeShowPageNumber, onRequestImage, onInsertTextBox, onPageChromeEditingPartChange, onClosePageChrome, onTogglePageChromePageNumber, onToggleLayout, onLayoutChange, onOpenLayout, onToggleNavigation, onTogglePageNumbers, onToggleHiddenText, onToggleRulers, onPageColorChange, onToggleSpellcheck, onViewModeChange, onZoomChange, onZoomFit, onInsertSection, onInsertNote, onInsertCaption, onInsertCrossReference, onOpenTableOfContents, onOpenIndexEntry, onOpenIndex, citationsOpen, citationSourceCount, onToggleCitations, onInsertField, onRefreshFields, onRefreshIndex, onRefreshTableOfContents, canInsertComment, onInsertComment, commentsOpen, commentCount, onToggleComments, trackChanges, changesOpen, changeCount, findReplaceMode, fileActions, onRibbonTabChange, onToggleTrackChanges, onToggleChanges, onOpenComparison, onDecideChange, onOpenWordCount, onOpenFindReplace }) {
15742
16120
  const [activeTab, setActiveTab] = useState(reviewOnly ? 'review' : 'home');
15743
16121
  const [fontDialogRequest, setFontDialogRequest] = useState(null);
15744
16122
  const [proofingDialogRequest, setProofingDialogRequest] = useState(null);
15745
16123
  const officeDialog = useOfficeDialog();
15746
16124
  const prompt = officeDialog.prompt;
15747
16125
  const imageSelected = editor.isActive('image');
16126
+ const textBoxSelected = editor.isActive('documentTextBox');
15748
16127
  const tableSelected = editor.isActive('table');
15749
16128
  const activeBookmark = activeDocumentBookmark(editor);
15750
16129
  const hasRefreshableFields = documentHasRefreshableFields(editor);
@@ -15786,6 +16165,9 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
15786
16165
  const ribbonTabs = reviewOnly ? documentRibbonTabs.filter(({ id })=>'review' === id || 'view' === id) : pageChromeEditor ? [
15787
16166
  ...documentRibbonTabs,
15788
16167
  documentPageChromeRibbonTab
16168
+ ] : textBoxSelected ? [
16169
+ ...documentRibbonTabs,
16170
+ documentTextBoxRibbonTab
15789
16171
  ] : imageSelected ? [
15790
16172
  ...documentRibbonTabs,
15791
16173
  documentPictureRibbonTab
@@ -15840,15 +16222,17 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
15840
16222
  setActiveTab((current)=>{
15841
16223
  if (reviewOnly) return 'view' === current ? 'view' : 'review';
15842
16224
  if (pageChromeEditor) return 'pageChrome';
16225
+ if (textBoxSelected) return 'textBox';
15843
16226
  if (imageSelected) return 'picture';
15844
16227
  if (tableSelected) return 'tableDesign' === current || 'tableLayout' === current ? current : 'tableDesign';
15845
- return 'picture' === current || 'tableDesign' === current || 'tableLayout' === current || 'pageChrome' === current ? 'home' : current;
16228
+ return 'picture' === current || 'textBox' === current || 'tableDesign' === current || 'tableLayout' === current || 'pageChrome' === current ? 'home' : current;
15846
16229
  });
15847
16230
  }, [
15848
16231
  imageSelected,
15849
16232
  pageChromeEditor,
15850
16233
  reviewOnly,
15851
- tableSelected
16234
+ tableSelected,
16235
+ textBoxSelected
15852
16236
  ]);
15853
16237
  useEffect(()=>{
15854
16238
  let editorDom = null;
@@ -16136,12 +16520,22 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
16136
16520
  })
16137
16521
  ]
16138
16522
  }),
16139
- /*#__PURE__*/ jsx(document_toolbar_RibbonGroup, {
16523
+ /*#__PURE__*/ jsxs(document_toolbar_RibbonGroup, {
16140
16524
  label: "文本",
16141
16525
  priority: "low",
16142
- children: /*#__PURE__*/ jsx(DocumentFieldSelect, {
16143
- onInsertField: onInsertField
16144
- })
16526
+ children: [
16527
+ /*#__PURE__*/ jsx(document_toolbar_ToolbarButton, {
16528
+ label: "插入文本框",
16529
+ displayLabel: true,
16530
+ onClick: ()=>onInsertTextBox?.(),
16531
+ children: /*#__PURE__*/ jsx(TextCursorInput, {
16532
+ size: 19
16533
+ })
16534
+ }),
16535
+ /*#__PURE__*/ jsx(DocumentFieldSelect, {
16536
+ onInsertField: onInsertField
16537
+ })
16538
+ ]
16145
16539
  })
16146
16540
  ]
16147
16541
  }),
@@ -16453,6 +16847,9 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
16453
16847
  onOpenFontDialog: ()=>openFontDialog(pageChromeEditor),
16454
16848
  onOpenProofingDialog: ()=>openProofingDialog(pageChromeEditor),
16455
16849
  onClose: onClosePageChrome
16850
+ }) : null,
16851
+ textBox: textBoxSelected ? /*#__PURE__*/ jsx(DocumentTextBoxRibbon, {
16852
+ editor: editor
16456
16853
  }) : null
16457
16854
  }
16458
16855
  }),
@@ -18443,6 +18840,12 @@ function useDocumentInsertCommands({ contentRef, editor, resolveFieldContext })
18443
18840
  const insertNote = useCallback((kind)=>editor?.chain().focus().insertDocumentNote(kind).run() ?? false, [
18444
18841
  editor
18445
18842
  ]);
18843
+ const insertTextBox = useCallback(()=>{
18844
+ if (!editor || editor.isDestroyed) return false;
18845
+ return editor.chain().focus().insertDocumentTextBox().run();
18846
+ }, [
18847
+ editor
18848
+ ]);
18446
18849
  const insertCaption = useCallback((kind)=>{
18447
18850
  if (!editor) return;
18448
18851
  rememberInvoker();
@@ -18770,6 +19173,7 @@ function useDocumentInsertCommands({ contentRef, editor, resolveFieldContext })
18770
19173
  insertField,
18771
19174
  insertImage,
18772
19175
  insertNote,
19176
+ insertTextBox,
18773
19177
  openIndexEntry,
18774
19178
  openIndex,
18775
19179
  openTableOfContents,
@@ -20975,6 +21379,7 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
20975
21379
  pageChromeEditingPart: pageChromeEditing?.part ?? null,
20976
21380
  pageChromeShowPageNumber: visibleChrome.showPageNumber,
20977
21381
  onRequestImage: ()=>imageInputRef.current?.click(),
21382
+ onInsertTextBox: documentInsert.insertTextBox,
20978
21383
  onPageChromeEditingPartChange: editPageChrome,
20979
21384
  onClosePageChrome: closePageChrome,
20980
21385
  onTogglePageChromePageNumber: toggleVisiblePageNumber,