@portone/docx-editor 0.1.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.
- package/CHANGELOG.md +7 -0
- package/CONTRIBUTING.md +63 -0
- package/LICENSE +203 -0
- package/README.md +48 -0
- package/assets/editor.png +0 -0
- package/dist/DocxEditor.d.ts +123 -0
- package/dist/DocxEditor.js +348 -0
- package/dist/core.d.ts +36 -0
- package/dist/core.js +38 -0
- package/dist/docx/comments/constants.d.ts +8 -0
- package/dist/docx/comments/constants.js +20 -0
- package/dist/docx/comments/model.d.ts +37 -0
- package/dist/docx/comments/model.js +104 -0
- package/dist/docx/comments/reading.d.ts +36 -0
- package/dist/docx/comments/reading.js +149 -0
- package/dist/docx/comments/writing.d.ts +11 -0
- package/dist/docx/comments/writing.js +327 -0
- package/dist/docx/comments.d.ts +3 -0
- package/dist/docx/comments.js +4 -0
- package/dist/docx/container.d.ts +12 -0
- package/dist/docx/container.js +130 -0
- package/dist/docx/documentSettings.d.ts +4 -0
- package/dist/docx/documentSettings.js +14 -0
- package/dist/docx/exportDocx.d.ts +15 -0
- package/dist/docx/exportDocx.js +163 -0
- package/dist/docx/exportRefs.d.ts +16 -0
- package/dist/docx/exportRefs.js +10 -0
- package/dist/docx/formatting/direct.d.ts +30 -0
- package/dist/docx/formatting/direct.js +201 -0
- package/dist/docx/formatting/effectiveParagraph.d.ts +15 -0
- package/dist/docx/formatting/effectiveParagraph.js +81 -0
- package/dist/docx/formatting/styles.d.ts +67 -0
- package/dist/docx/formatting/styles.js +165 -0
- package/dist/docx/formatting/tabStops.d.ts +8 -0
- package/dist/docx/formatting/tabStops.js +65 -0
- package/dist/docx/formatting.d.ts +4 -0
- package/dist/docx/formatting.js +4 -0
- package/dist/docx/headersFooters.d.ts +36 -0
- package/dist/docx/headersFooters.js +218 -0
- package/dist/docx/hyperlink.d.ts +75 -0
- package/dist/docx/hyperlink.js +71 -0
- package/dist/docx/importDocx.d.ts +21 -0
- package/dist/docx/importDocx.js +263 -0
- package/dist/docx/importParagraph.d.ts +32 -0
- package/dist/docx/importParagraph.js +308 -0
- package/dist/docx/importTable.d.ts +9 -0
- package/dist/docx/importTable.js +275 -0
- package/dist/docx/media.d.ts +60 -0
- package/dist/docx/media.js +213 -0
- package/dist/docx/notes.d.ts +22 -0
- package/dist/docx/notes.js +71 -0
- package/dist/docx/pageGeometry.d.ts +75 -0
- package/dist/docx/pageGeometry.js +88 -0
- package/dist/docx/paraProps.d.ts +74 -0
- package/dist/docx/paraProps.js +167 -0
- package/dist/docx/propsXml.d.ts +49 -0
- package/dist/docx/propsXml.js +302 -0
- package/dist/docx/relationships.d.ts +42 -0
- package/dist/docx/relationships.js +94 -0
- package/dist/docx/runProps.d.ts +51 -0
- package/dist/docx/runProps.js +207 -0
- package/dist/docx/scan.d.ts +20 -0
- package/dist/docx/scan.js +110 -0
- package/dist/docx/sdt.d.ts +56 -0
- package/dist/docx/sdt.js +104 -0
- package/dist/docx/sdtProps.d.ts +18 -0
- package/dist/docx/sdtProps.js +11 -0
- package/dist/docx/serializeBlock.d.ts +4 -0
- package/dist/docx/serializeBlock.js +30 -0
- package/dist/docx/serializeParagraph.d.ts +15 -0
- package/dist/docx/serializeParagraph.js +208 -0
- package/dist/docx/serializeTable.d.ts +12 -0
- package/dist/docx/serializeTable.js +134 -0
- package/dist/docx/session.d.ts +81 -0
- package/dist/docx/session.js +79 -0
- package/dist/docx/tableFormatting/editing.d.ts +64 -0
- package/dist/docx/tableFormatting/editing.js +318 -0
- package/dist/docx/tableFormatting/reading.d.ts +96 -0
- package/dist/docx/tableFormatting/reading.js +221 -0
- package/dist/docx/tableFormatting.d.ts +2 -0
- package/dist/docx/tableFormatting.js +3 -0
- package/dist/docx/tableTemplate.d.ts +22 -0
- package/dist/docx/tableTemplate.js +111 -0
- package/dist/docx/theme.d.ts +40 -0
- package/dist/docx/theme.js +61 -0
- package/dist/docx/uniqueControls.d.ts +14 -0
- package/dist/docx/uniqueControls.js +62 -0
- package/dist/download.d.ts +57 -0
- package/dist/download.js +44 -0
- package/dist/editor/clipboard/images.d.ts +14 -0
- package/dist/editor/clipboard/images.js +158 -0
- package/dist/editor/clipboard/inlineFormatting.d.ts +21 -0
- package/dist/editor/clipboard/inlineFormatting.js +232 -0
- package/dist/editor/commands/breakCommands.d.ts +8 -0
- package/dist/editor/commands/breakCommands.js +19 -0
- package/dist/editor/commands/canRunCommand.d.ts +6 -0
- package/dist/editor/commands/canRunCommand.js +10 -0
- package/dist/editor/commands/commentCommands.d.ts +3 -0
- package/dist/editor/commands/commentCommands.js +4 -0
- package/dist/editor/commands/comments/editing.d.ts +21 -0
- package/dist/editor/commands/comments/editing.js +305 -0
- package/dist/editor/commands/comments/model.d.ts +31 -0
- package/dist/editor/commands/comments/model.js +0 -0
- package/dist/editor/commands/comments/reading.d.ts +8 -0
- package/dist/editor/commands/comments/reading.js +58 -0
- package/dist/editor/commands/formatting/editing.d.ts +32 -0
- package/dist/editor/commands/formatting/editing.js +138 -0
- package/dist/editor/commands/formatting/reading.d.ts +57 -0
- package/dist/editor/commands/formatting/reading.js +82 -0
- package/dist/editor/commands/formatting/shared.d.ts +32 -0
- package/dist/editor/commands/formatting/shared.js +53 -0
- package/dist/editor/commands/formattingCommands.d.ts +2 -0
- package/dist/editor/commands/formattingCommands.js +3 -0
- package/dist/editor/commands/historyCommands.d.ts +11 -0
- package/dist/editor/commands/historyCommands.js +16 -0
- package/dist/editor/commands/indentCommands.d.ts +15 -0
- package/dist/editor/commands/indentCommands.js +44 -0
- package/dist/editor/commands/index.d.ts +82 -0
- package/dist/editor/commands/index.js +171 -0
- package/dist/editor/commands/linkCommands.d.ts +56 -0
- package/dist/editor/commands/linkCommands.js +146 -0
- package/dist/editor/commands/listCommands.d.ts +58 -0
- package/dist/editor/commands/listCommands.js +140 -0
- package/dist/editor/commands/lockCommands.d.ts +47 -0
- package/dist/editor/commands/lockCommands.js +198 -0
- package/dist/editor/commands/noteQueries.d.ts +12 -0
- package/dist/editor/commands/noteQueries.js +29 -0
- package/dist/editor/commands/paragraphCommands.d.ts +59 -0
- package/dist/editor/commands/paragraphCommands.js +113 -0
- package/dist/editor/commands/spacingCommands.d.ts +23 -0
- package/dist/editor/commands/spacingCommands.js +48 -0
- package/dist/editor/commands/tabCommands.d.ts +5 -0
- package/dist/editor/commands/tabCommands.js +65 -0
- package/dist/editor/createEditor.d.ts +59 -0
- package/dist/editor/createEditor.js +160 -0
- package/dist/editor/documentStyles.d.ts +60 -0
- package/dist/editor/documentStyles.js +80 -0
- package/dist/editor/externalClipboard.d.ts +11 -0
- package/dist/editor/externalClipboard.js +323 -0
- package/dist/editor/imageFiles.d.ts +74 -0
- package/dist/editor/imageFiles.js +173 -0
- package/dist/editor/insertImage.d.ts +31 -0
- package/dist/editor/insertImage.js +35 -0
- package/dist/editor/insertTable.d.ts +18 -0
- package/dist/editor/insertTable.js +44 -0
- package/dist/editor/paragraphEdits.d.ts +42 -0
- package/dist/editor/paragraphEdits.js +59 -0
- package/dist/editor/plainText.d.ts +3 -0
- package/dist/editor/plainText.js +50 -0
- package/dist/editor/plugins/bookmarkProtection.d.ts +3 -0
- package/dist/editor/plugins/bookmarkProtection.js +28 -0
- package/dist/editor/plugins/columnResize.d.ts +27 -0
- package/dist/editor/plugins/columnResize.js +192 -0
- package/dist/editor/plugins/commentDecorations.d.ts +3 -0
- package/dist/editor/plugins/commentDecorations.js +23 -0
- package/dist/editor/plugins/commentReservations.d.ts +5 -0
- package/dist/editor/plugins/commentReservations.js +26 -0
- package/dist/editor/plugins/dropCaret.d.ts +10 -0
- package/dist/editor/plugins/dropCaret.js +11 -0
- package/dist/editor/plugins/imagePaste.d.ts +8 -0
- package/dist/editor/plugins/imagePaste.js +265 -0
- package/dist/editor/plugins/keymap.d.ts +5 -0
- package/dist/editor/plugins/keymap.js +94 -0
- package/dist/editor/plugins/linkPanel.d.ts +23 -0
- package/dist/editor/plugins/linkPanel.js +39 -0
- package/dist/editor/plugins/listInputRules.d.ts +14 -0
- package/dist/editor/plugins/listInputRules.js +36 -0
- package/dist/editor/plugins/lockedContent.d.ts +6 -0
- package/dist/editor/plugins/lockedContent.js +41 -0
- package/dist/editor/plugins/noteProtection.d.ts +3 -0
- package/dist/editor/plugins/noteProtection.js +25 -0
- package/dist/editor/plugins/numberingDecorations.d.ts +42 -0
- package/dist/editor/plugins/numberingDecorations.js +110 -0
- package/dist/editor/plugins/rowResize.d.ts +15 -0
- package/dist/editor/plugins/rowResize.js +196 -0
- package/dist/editor/plugins/styledParagraphs.d.ts +15 -0
- package/dist/editor/plugins/styledParagraphs.js +65 -0
- package/dist/editor/plugins/tabCaret.d.ts +3 -0
- package/dist/editor/plugins/tabCaret.js +126 -0
- package/dist/editor/plugins/tabDecorations.d.ts +11 -0
- package/dist/editor/plugins/tabDecorations.js +87 -0
- package/dist/editor/plugins/tabLayout.d.ts +16 -0
- package/dist/editor/plugins/tabLayout.js +328 -0
- package/dist/editor/plugins/tabPointer.d.ts +7 -0
- package/dist/editor/plugins/tabPointer.js +95 -0
- package/dist/editor/plugins/tableContextMenu.d.ts +21 -0
- package/dist/editor/plugins/tableContextMenu.js +88 -0
- package/dist/editor/plugins/textContextMenu.d.ts +15 -0
- package/dist/editor/plugins/textContextMenu.js +90 -0
- package/dist/editor/views/imageResize.d.ts +53 -0
- package/dist/editor/views/imageResize.js +167 -0
- package/dist/editor/views/runMarkView.d.ts +15 -0
- package/dist/editor/views/runMarkView.js +9 -0
- package/dist/editor/views/tableView.d.ts +24 -0
- package/dist/editor/views/tableView.js +32 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +38 -0
- package/dist/model/format.d.ts +240 -0
- package/dist/model/format.js +305 -0
- package/dist/model/tabStops.d.ts +17 -0
- package/dist/model/tabStops.js +22 -0
- package/dist/numbering/listTemplate.d.ts +29 -0
- package/dist/numbering/listTemplate.js +83 -0
- package/dist/numbering/markers.d.ts +24 -0
- package/dist/numbering/markers.js +93 -0
- package/dist/numbering/parseNumbering.d.ts +65 -0
- package/dist/numbering/parseNumbering.js +116 -0
- package/dist/numbering/writeNumbering.d.ts +13 -0
- package/dist/numbering/writeNumbering.js +49 -0
- package/dist/ooxml/errors.d.ts +39 -0
- package/dist/ooxml/errors.js +21 -0
- package/dist/ooxml/image.d.ts +88 -0
- package/dist/ooxml/image.js +106 -0
- package/dist/ooxml/tabStops.d.ts +3 -0
- package/dist/ooxml/tabStops.js +51 -0
- package/dist/ooxml/units.d.ts +37 -0
- package/dist/ooxml/units.js +116 -0
- package/dist/ooxml/xml.d.ts +36 -0
- package/dist/ooxml/xml.js +89 -0
- package/dist/page/PageGuides.d.ts +16 -0
- package/dist/page/PageGuides.js +114 -0
- package/dist/page/measureBlocks.d.ts +25 -0
- package/dist/page/measureBlocks.js +80 -0
- package/dist/page/pageDecorations.d.ts +36 -0
- package/dist/page/pageDecorations.js +211 -0
- package/dist/page/pageLayout.d.ts +176 -0
- package/dist/page/pageLayout.js +157 -0
- package/dist/page/tableMeasurements.d.ts +10 -0
- package/dist/page/tableMeasurements.js +115 -0
- package/dist/page/usePageLayout.d.ts +57 -0
- package/dist/page/usePageLayout.js +141 -0
- package/dist/schema/docxSchema.d.ts +9 -0
- package/dist/schema/docxSchema.js +863 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +9 -0
- package/dist/schema/locks.d.ts +112 -0
- package/dist/schema/locks.js +211 -0
- package/dist/schema/rendering.d.ts +6 -0
- package/dist/schema/rendering.js +46 -0
- package/dist/styles/classNames.d.ts +214 -0
- package/dist/styles/classNames.js +208 -0
- package/dist/styles/colors.d.ts +11 -0
- package/dist/styles/colors.js +14 -0
- package/dist/styles/fontSizes.d.ts +6 -0
- package/dist/styles/fontSizes.js +20 -0
- package/dist/styles/fontStack.d.ts +55 -0
- package/dist/styles/fontStack.js +262 -0
- package/dist/styles/fonts.d.ts +6 -0
- package/dist/styles/fonts.js +11 -0
- package/dist/styles/inlineStyle.d.ts +67 -0
- package/dist/styles/inlineStyle.js +212 -0
- package/dist/styles/lineSpacings.d.ts +11 -0
- package/dist/styles/lineSpacings.js +10 -0
- package/dist/styles.css +1650 -0
- package/dist/table/cellBorders.d.ts +12 -0
- package/dist/table/cellBorders.js +9 -0
- package/dist/table/cellFormatting.d.ts +57 -0
- package/dist/table/cellFormatting.js +173 -0
- package/dist/table/columns.d.ts +25 -0
- package/dist/table/columns.js +155 -0
- package/dist/table/commands.d.ts +19 -0
- package/dist/table/commands.js +63 -0
- package/dist/table/format.d.ts +35 -0
- package/dist/table/format.js +26 -0
- package/dist/table/gridBorders.d.ts +42 -0
- package/dist/table/gridBorders.js +192 -0
- package/dist/table/index.d.ts +16 -0
- package/dist/table/index.js +52 -0
- package/dist/table/merge.d.ts +36 -0
- package/dist/table/merge.js +125 -0
- package/dist/table/resize.d.ts +55 -0
- package/dist/table/resize.js +66 -0
- package/dist/table/rowResize.d.ts +14 -0
- package/dist/table/rowResize.js +44 -0
- package/dist/table/rows.d.ts +32 -0
- package/dist/table/rows.js +89 -0
- package/dist/table/widths.d.ts +69 -0
- package/dist/table/widths.js +97 -0
- package/dist/ui/AlignMenu.d.ts +15 -0
- package/dist/ui/AlignMenu.js +64 -0
- package/dist/ui/CellStyleGroup.d.ts +15 -0
- package/dist/ui/CellStyleGroup.js +232 -0
- package/dist/ui/ColorPicker.d.ts +13 -0
- package/dist/ui/ColorPicker.js +165 -0
- package/dist/ui/CommentsPanel.d.ts +15 -0
- package/dist/ui/CommentsPanel.js +348 -0
- package/dist/ui/FontFamilySelect.d.ts +14 -0
- package/dist/ui/FontFamilySelect.js +59 -0
- package/dist/ui/FontSizeSelect.d.ts +11 -0
- package/dist/ui/FontSizeSelect.js +49 -0
- package/dist/ui/InsertImageButton.d.ts +9 -0
- package/dist/ui/InsertImageButton.js +47 -0
- package/dist/ui/LinkCard.d.ts +12 -0
- package/dist/ui/LinkCard.js +127 -0
- package/dist/ui/LinkPanel.d.ts +9 -0
- package/dist/ui/LinkPanel.js +121 -0
- package/dist/ui/MenuChoice.d.ts +11 -0
- package/dist/ui/MenuChoice.js +32 -0
- package/dist/ui/NotesPanel.d.ts +6 -0
- package/dist/ui/NotesPanel.js +33 -0
- package/dist/ui/ParagraphStyleSelect.d.ts +11 -0
- package/dist/ui/ParagraphStyleSelect.js +62 -0
- package/dist/ui/Popover.d.ts +22 -0
- package/dist/ui/Popover.js +74 -0
- package/dist/ui/SpacingMenu.d.ts +12 -0
- package/dist/ui/SpacingMenu.js +54 -0
- package/dist/ui/TableMenu.d.ts +12 -0
- package/dist/ui/TableMenu.js +112 -0
- package/dist/ui/TableSizePicker.d.ts +9 -0
- package/dist/ui/TableSizePicker.js +53 -0
- package/dist/ui/TextMenu.d.ts +15 -0
- package/dist/ui/TextMenu.js +194 -0
- package/dist/ui/Toolbar.d.ts +19 -0
- package/dist/ui/Toolbar.js +448 -0
- package/dist/ui/ToolbarButton.d.ts +23 -0
- package/dist/ui/ToolbarButton.js +56 -0
- package/dist/ui/Tooltip.d.ts +19 -0
- package/dist/ui/Tooltip.js +47 -0
- package/dist/ui/ZoomSelect.d.ts +7 -0
- package/dist/ui/ZoomSelect.js +44 -0
- package/dist/ui/comments/CommentComposer.d.ts +17 -0
- package/dist/ui/comments/CommentComposer.js +59 -0
- package/dist/ui/comments/useCommentRailLayout.d.ts +18 -0
- package/dist/ui/comments/useCommentRailLayout.js +183 -0
- package/dist/ui/keyboardWalk.d.ts +22 -0
- package/dist/ui/keyboardWalk.js +70 -0
- package/dist/ui/openAddress.d.ts +11 -0
- package/dist/ui/openAddress.js +16 -0
- package/dist/ui/panelPlacement.d.ts +51 -0
- package/dist/ui/panelPlacement.js +71 -0
- package/dist/ui/presets.d.ts +11 -0
- package/dist/ui/presets.js +0 -0
- package/dist/ui/rovingFocus.d.ts +20 -0
- package/dist/ui/rovingFocus.js +61 -0
- package/dist/ui/runCommand.d.ts +5 -0
- package/dist/ui/runCommand.js +13 -0
- package/dist/ui/useDismiss.d.ts +6 -0
- package/dist/ui/useDismiss.js +31 -0
- package/dist/ui/useFitWidthZoom.d.ts +2 -0
- package/dist/ui/useFitWidthZoom.js +26 -0
- package/dist/ui/useGridKeyboard.d.ts +12 -0
- package/dist/ui/useGridKeyboard.js +90 -0
- package/dist/ui/useMenuKeyboard.d.ts +12 -0
- package/dist/ui/useMenuKeyboard.js +56 -0
- package/dist/ui/zoom.d.ts +4 -0
- package/dist/ui/zoom.js +21 -0
- package/package.json +120 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
// src/ui/Toolbar.tsx
|
|
2
|
+
import {
|
|
3
|
+
Baseline,
|
|
4
|
+
Bold,
|
|
5
|
+
Highlighter,
|
|
6
|
+
IndentDecrease,
|
|
7
|
+
IndentIncrease,
|
|
8
|
+
Italic,
|
|
9
|
+
Link,
|
|
10
|
+
List,
|
|
11
|
+
ListChevronsUpDown,
|
|
12
|
+
ListOrdered,
|
|
13
|
+
MessagesSquare,
|
|
14
|
+
Redo2,
|
|
15
|
+
Strikethrough,
|
|
16
|
+
Table,
|
|
17
|
+
Underline,
|
|
18
|
+
Undo2
|
|
19
|
+
} from "lucide-react";
|
|
20
|
+
import { useMemo, useRef } from "react";
|
|
21
|
+
import {
|
|
22
|
+
activeFontFamily,
|
|
23
|
+
activeFontSize,
|
|
24
|
+
activeTextBackground,
|
|
25
|
+
activeTextColor,
|
|
26
|
+
canFormatText,
|
|
27
|
+
documentFontNames,
|
|
28
|
+
isBoldActive,
|
|
29
|
+
isItalicActive,
|
|
30
|
+
isStrikeActive,
|
|
31
|
+
isUnderlineActive,
|
|
32
|
+
setTextBackground,
|
|
33
|
+
setTextColor,
|
|
34
|
+
toggleBold,
|
|
35
|
+
toggleItalic,
|
|
36
|
+
toggleStrike,
|
|
37
|
+
toggleUnderline
|
|
38
|
+
} from "../editor/commands/formattingCommands.js";
|
|
39
|
+
import { redo, undo } from "../editor/commands/historyCommands.js";
|
|
40
|
+
import {
|
|
41
|
+
canDecreaseIndent,
|
|
42
|
+
canIncreaseIndent,
|
|
43
|
+
decreaseIndent,
|
|
44
|
+
increaseIndent
|
|
45
|
+
} from "../editor/commands/indentCommands.js";
|
|
46
|
+
import {
|
|
47
|
+
activeListKind,
|
|
48
|
+
toggleBulletList,
|
|
49
|
+
toggleNumberedList
|
|
50
|
+
} from "../editor/commands/listCommands.js";
|
|
51
|
+
import {
|
|
52
|
+
activeParagraphAlign,
|
|
53
|
+
activeParagraphStyle,
|
|
54
|
+
canSetParagraphAlign
|
|
55
|
+
} from "../editor/commands/paragraphCommands.js";
|
|
56
|
+
import { canSetLineSpacing } from "../editor/commands/spacingCommands.js";
|
|
57
|
+
import {
|
|
58
|
+
documentDefaults,
|
|
59
|
+
documentParagraphStyles
|
|
60
|
+
} from "../editor/documentStyles.js";
|
|
61
|
+
import { canInsertTable } from "../editor/insertTable.js";
|
|
62
|
+
import { openLinkPanel } from "../editor/plugins/linkPanel.js";
|
|
63
|
+
import { editorClassNames } from "../styles/classNames.js";
|
|
64
|
+
import { AlignMenu, alignIcon } from "./AlignMenu.js";
|
|
65
|
+
import { CellStyleGroup } from "./CellStyleGroup.js";
|
|
66
|
+
import { ColorPicker } from "./ColorPicker.js";
|
|
67
|
+
import { FontFamilySelect } from "./FontFamilySelect.js";
|
|
68
|
+
import { FontSizeSelect } from "./FontSizeSelect.js";
|
|
69
|
+
import { InsertImageButton } from "./InsertImageButton.js";
|
|
70
|
+
import { useLinearWalk } from "./keyboardWalk.js";
|
|
71
|
+
import { ParagraphStyleSelect } from "./ParagraphStyleSelect.js";
|
|
72
|
+
import { Popover } from "./Popover.js";
|
|
73
|
+
import { commandRunner } from "./runCommand.js";
|
|
74
|
+
import { SpacingMenu } from "./SpacingMenu.js";
|
|
75
|
+
import { TableSizePicker } from "./TableSizePicker.js";
|
|
76
|
+
import { ToolbarButton } from "./ToolbarButton.js";
|
|
77
|
+
import { hushedAttribute, useTooltipsHushed } from "./Tooltip.js";
|
|
78
|
+
import { ZoomSelect } from "./ZoomSelect.js";
|
|
79
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
80
|
+
var TEXT_TOGGLES = [
|
|
81
|
+
{ label: "Bold", icon: Bold, command: toggleBold, active: isBoldActive },
|
|
82
|
+
{
|
|
83
|
+
label: "Italic",
|
|
84
|
+
icon: Italic,
|
|
85
|
+
command: toggleItalic,
|
|
86
|
+
active: isItalicActive
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
label: "Underline",
|
|
90
|
+
icon: Underline,
|
|
91
|
+
command: toggleUnderline,
|
|
92
|
+
active: isUnderlineActive
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
label: "Strikethrough",
|
|
96
|
+
icon: Strikethrough,
|
|
97
|
+
command: toggleStrike,
|
|
98
|
+
active: isStrikeActive
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
var LIST_TOGGLES = [
|
|
102
|
+
{
|
|
103
|
+
label: "Numbered list",
|
|
104
|
+
icon: ListOrdered,
|
|
105
|
+
kind: "numbered",
|
|
106
|
+
command: toggleNumberedList
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
label: "Bulleted list",
|
|
110
|
+
icon: List,
|
|
111
|
+
kind: "bullet",
|
|
112
|
+
command: toggleBulletList
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
var INDENTS = [
|
|
116
|
+
{
|
|
117
|
+
label: "Decrease indent",
|
|
118
|
+
icon: IndentDecrease,
|
|
119
|
+
command: decreaseIndent,
|
|
120
|
+
enabled: canDecreaseIndent
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
label: "Increase indent",
|
|
124
|
+
icon: IndentIncrease,
|
|
125
|
+
command: increaseIndent,
|
|
126
|
+
enabled: canIncreaseIndent
|
|
127
|
+
}
|
|
128
|
+
];
|
|
129
|
+
function Separator() {
|
|
130
|
+
return /* @__PURE__ */ jsx("span", { className: editorClassNames.toolbarSeparator });
|
|
131
|
+
}
|
|
132
|
+
var TOOLBAR_CONTROLS = `.${editorClassNames.toolbarButton},.${editorClassNames.toolbarSelect}`;
|
|
133
|
+
function isLive(control) {
|
|
134
|
+
return !control.matches(":disabled");
|
|
135
|
+
}
|
|
136
|
+
function HistoryGroup({ state, run }) {
|
|
137
|
+
return /* @__PURE__ */ jsxs("div", { className: editorClassNames.toolbarGroup, children: [
|
|
138
|
+
/* @__PURE__ */ jsx(
|
|
139
|
+
ToolbarButton,
|
|
140
|
+
{
|
|
141
|
+
label: "Undo",
|
|
142
|
+
icon: Undo2,
|
|
143
|
+
disabled: !undo(state),
|
|
144
|
+
onRun: () => run(undo)
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
/* @__PURE__ */ jsx(
|
|
148
|
+
ToolbarButton,
|
|
149
|
+
{
|
|
150
|
+
label: "Redo",
|
|
151
|
+
icon: Redo2,
|
|
152
|
+
disabled: !redo(state),
|
|
153
|
+
onRun: () => run(redo)
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
] });
|
|
157
|
+
}
|
|
158
|
+
function TextToggleGroup({
|
|
159
|
+
state,
|
|
160
|
+
run,
|
|
161
|
+
disabled
|
|
162
|
+
}) {
|
|
163
|
+
return /* @__PURE__ */ jsx("div", { className: editorClassNames.toolbarGroup, children: TEXT_TOGGLES.map((toggle) => /* @__PURE__ */ jsx(
|
|
164
|
+
ToolbarButton,
|
|
165
|
+
{
|
|
166
|
+
label: toggle.label,
|
|
167
|
+
icon: toggle.icon,
|
|
168
|
+
pressed: toggle.active(state),
|
|
169
|
+
disabled,
|
|
170
|
+
onRun: () => run(toggle.command)
|
|
171
|
+
},
|
|
172
|
+
toggle.label
|
|
173
|
+
)) });
|
|
174
|
+
}
|
|
175
|
+
function ColorGroup({
|
|
176
|
+
state,
|
|
177
|
+
colors,
|
|
178
|
+
run,
|
|
179
|
+
disabled
|
|
180
|
+
}) {
|
|
181
|
+
return /* @__PURE__ */ jsxs("div", { className: editorClassNames.toolbarGroup, children: [
|
|
182
|
+
/* @__PURE__ */ jsx(
|
|
183
|
+
Popover,
|
|
184
|
+
{
|
|
185
|
+
label: "Text color",
|
|
186
|
+
icon: Baseline,
|
|
187
|
+
indicatorColor: activeTextColor(state) ?? "#000000",
|
|
188
|
+
panel: "dialog",
|
|
189
|
+
disabled,
|
|
190
|
+
children: ({ close, takeFocus }) => /* @__PURE__ */ jsx(
|
|
191
|
+
ColorPicker,
|
|
192
|
+
{
|
|
193
|
+
current: activeTextColor(state),
|
|
194
|
+
colors,
|
|
195
|
+
close,
|
|
196
|
+
takeFocus,
|
|
197
|
+
onPick: (hex) => {
|
|
198
|
+
run(setTextColor(hex));
|
|
199
|
+
close();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
/* @__PURE__ */ jsx(
|
|
206
|
+
Popover,
|
|
207
|
+
{
|
|
208
|
+
label: "Highlight",
|
|
209
|
+
icon: Highlighter,
|
|
210
|
+
indicatorColor: activeTextBackground(state) ?? "transparent",
|
|
211
|
+
panel: "dialog",
|
|
212
|
+
disabled,
|
|
213
|
+
children: ({ close, takeFocus }) => /* @__PURE__ */ jsx(
|
|
214
|
+
ColorPicker,
|
|
215
|
+
{
|
|
216
|
+
current: activeTextBackground(state),
|
|
217
|
+
colors,
|
|
218
|
+
close,
|
|
219
|
+
takeFocus,
|
|
220
|
+
onPick: (hex) => {
|
|
221
|
+
run(setTextBackground(hex));
|
|
222
|
+
close();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
)
|
|
228
|
+
] });
|
|
229
|
+
}
|
|
230
|
+
function ParagraphLayoutGroup({
|
|
231
|
+
state,
|
|
232
|
+
lineSpacings,
|
|
233
|
+
run
|
|
234
|
+
}) {
|
|
235
|
+
return /* @__PURE__ */ jsxs("div", { className: editorClassNames.toolbarGroup, children: [
|
|
236
|
+
/* @__PURE__ */ jsx(
|
|
237
|
+
Popover,
|
|
238
|
+
{
|
|
239
|
+
label: "Alignment",
|
|
240
|
+
icon: alignIcon(activeParagraphAlign(state)),
|
|
241
|
+
panel: "menu",
|
|
242
|
+
disabled: !canSetParagraphAlign(state),
|
|
243
|
+
children: ({ close, takeFocus }) => /* @__PURE__ */ jsx(
|
|
244
|
+
AlignMenu,
|
|
245
|
+
{
|
|
246
|
+
state,
|
|
247
|
+
run,
|
|
248
|
+
close,
|
|
249
|
+
takeFocus
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
),
|
|
254
|
+
/* @__PURE__ */ jsx(
|
|
255
|
+
Popover,
|
|
256
|
+
{
|
|
257
|
+
label: "Line and paragraph spacing",
|
|
258
|
+
icon: ListChevronsUpDown,
|
|
259
|
+
panel: "menu",
|
|
260
|
+
disabled: !canSetLineSpacing(state),
|
|
261
|
+
children: ({ close, takeFocus }) => /* @__PURE__ */ jsx(
|
|
262
|
+
SpacingMenu,
|
|
263
|
+
{
|
|
264
|
+
state,
|
|
265
|
+
lineSpacings,
|
|
266
|
+
run,
|
|
267
|
+
close,
|
|
268
|
+
takeFocus
|
|
269
|
+
}
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
)
|
|
273
|
+
] });
|
|
274
|
+
}
|
|
275
|
+
function ListGroup({ state, run }) {
|
|
276
|
+
const kind = activeListKind(state);
|
|
277
|
+
return /* @__PURE__ */ jsx("div", { className: editorClassNames.toolbarGroup, children: LIST_TOGGLES.map((toggle) => /* @__PURE__ */ jsx(
|
|
278
|
+
ToolbarButton,
|
|
279
|
+
{
|
|
280
|
+
label: toggle.label,
|
|
281
|
+
icon: toggle.icon,
|
|
282
|
+
pressed: kind === toggle.kind,
|
|
283
|
+
disabled: !toggle.command(state),
|
|
284
|
+
onRun: () => run(toggle.command)
|
|
285
|
+
},
|
|
286
|
+
toggle.kind
|
|
287
|
+
)) });
|
|
288
|
+
}
|
|
289
|
+
function IndentGroup({ state, run }) {
|
|
290
|
+
return /* @__PURE__ */ jsx("div", { className: editorClassNames.toolbarGroup, children: INDENTS.map((indent) => /* @__PURE__ */ jsx(
|
|
291
|
+
ToolbarButton,
|
|
292
|
+
{
|
|
293
|
+
label: indent.label,
|
|
294
|
+
icon: indent.icon,
|
|
295
|
+
disabled: !indent.enabled(state),
|
|
296
|
+
onRun: () => run(indent.command)
|
|
297
|
+
},
|
|
298
|
+
indent.label
|
|
299
|
+
)) });
|
|
300
|
+
}
|
|
301
|
+
function Toolbar({
|
|
302
|
+
view,
|
|
303
|
+
state,
|
|
304
|
+
fontFallbacks,
|
|
305
|
+
presets,
|
|
306
|
+
onToggleComments,
|
|
307
|
+
commentsOpen = false,
|
|
308
|
+
zoom,
|
|
309
|
+
onZoomChange
|
|
310
|
+
}) {
|
|
311
|
+
const run = commandRunner(view);
|
|
312
|
+
const bar = useRef(null);
|
|
313
|
+
const keys = useLinearWalk({
|
|
314
|
+
container: bar,
|
|
315
|
+
selector: TOOLBAR_CONTROLS,
|
|
316
|
+
orientation: "horizontal",
|
|
317
|
+
navigable: isLive
|
|
318
|
+
});
|
|
319
|
+
const hushed = useTooltipsHushed();
|
|
320
|
+
const doc = state.doc;
|
|
321
|
+
const defaults = documentDefaults(state);
|
|
322
|
+
const formattable = canFormatText(state);
|
|
323
|
+
const documentFonts = useMemo(
|
|
324
|
+
() => documentFontNames(doc, defaults),
|
|
325
|
+
[doc, defaults]
|
|
326
|
+
);
|
|
327
|
+
const onKeyDown = (event) => {
|
|
328
|
+
const { target } = event;
|
|
329
|
+
if (target instanceof HTMLElement && target.matches(TOOLBAR_CONTROLS)) {
|
|
330
|
+
keys.walk(event);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
return /* @__PURE__ */ jsxs(
|
|
334
|
+
"div",
|
|
335
|
+
{
|
|
336
|
+
ref: bar,
|
|
337
|
+
className: editorClassNames.toolbar,
|
|
338
|
+
role: "toolbar",
|
|
339
|
+
"aria-label": "Editor toolbar",
|
|
340
|
+
onKeyDown,
|
|
341
|
+
...hushedAttribute(hushed),
|
|
342
|
+
children: [
|
|
343
|
+
/* @__PURE__ */ jsx(HistoryGroup, { state, run }),
|
|
344
|
+
/* @__PURE__ */ jsx(ZoomSelect, { zoom, onZoomChange }),
|
|
345
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
346
|
+
/* @__PURE__ */ jsxs("div", { className: editorClassNames.toolbarGroup, children: [
|
|
347
|
+
/* @__PURE__ */ jsx(
|
|
348
|
+
ParagraphStyleSelect,
|
|
349
|
+
{
|
|
350
|
+
current: activeParagraphStyle(state),
|
|
351
|
+
styles: documentParagraphStyles(state),
|
|
352
|
+
run
|
|
353
|
+
}
|
|
354
|
+
),
|
|
355
|
+
/* @__PURE__ */ jsx(
|
|
356
|
+
FontFamilySelect,
|
|
357
|
+
{
|
|
358
|
+
current: activeFontFamily(state, fontFallbacks),
|
|
359
|
+
documentFonts,
|
|
360
|
+
fonts: presets?.fonts,
|
|
361
|
+
fontFallbacks,
|
|
362
|
+
disabled: !formattable,
|
|
363
|
+
run
|
|
364
|
+
}
|
|
365
|
+
),
|
|
366
|
+
/* @__PURE__ */ jsx(
|
|
367
|
+
FontSizeSelect,
|
|
368
|
+
{
|
|
369
|
+
current: activeFontSize(state),
|
|
370
|
+
fontSizes: presets?.fontSizes,
|
|
371
|
+
disabled: !formattable,
|
|
372
|
+
run
|
|
373
|
+
}
|
|
374
|
+
)
|
|
375
|
+
] }),
|
|
376
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
377
|
+
/* @__PURE__ */ jsx(TextToggleGroup, { state, run, disabled: !formattable }),
|
|
378
|
+
/* @__PURE__ */ jsx(
|
|
379
|
+
ColorGroup,
|
|
380
|
+
{
|
|
381
|
+
state,
|
|
382
|
+
colors: presets?.colors,
|
|
383
|
+
run,
|
|
384
|
+
disabled: !formattable
|
|
385
|
+
}
|
|
386
|
+
),
|
|
387
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
388
|
+
/* @__PURE__ */ jsx(
|
|
389
|
+
ParagraphLayoutGroup,
|
|
390
|
+
{
|
|
391
|
+
state,
|
|
392
|
+
lineSpacings: presets?.lineSpacings,
|
|
393
|
+
run
|
|
394
|
+
}
|
|
395
|
+
),
|
|
396
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
397
|
+
/* @__PURE__ */ jsx(ListGroup, { state, run }),
|
|
398
|
+
/* @__PURE__ */ jsx(IndentGroup, { state, run }),
|
|
399
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
400
|
+
/* @__PURE__ */ jsx(
|
|
401
|
+
CellStyleGroup,
|
|
402
|
+
{
|
|
403
|
+
state,
|
|
404
|
+
cellBorders: presets?.cellBorders,
|
|
405
|
+
colors: presets?.colors,
|
|
406
|
+
run
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
410
|
+
/* @__PURE__ */ jsxs("div", { className: editorClassNames.toolbarGroup, children: [
|
|
411
|
+
/* @__PURE__ */ jsx(
|
|
412
|
+
Popover,
|
|
413
|
+
{
|
|
414
|
+
label: "Insert table",
|
|
415
|
+
icon: Table,
|
|
416
|
+
panel: "dialog",
|
|
417
|
+
disabled: !canInsertTable(state),
|
|
418
|
+
children: ({ close, takeFocus }) => /* @__PURE__ */ jsx(TableSizePicker, { run, close, takeFocus })
|
|
419
|
+
}
|
|
420
|
+
),
|
|
421
|
+
/* @__PURE__ */ jsx(InsertImageButton, { view, state }),
|
|
422
|
+
/* @__PURE__ */ jsx(
|
|
423
|
+
ToolbarButton,
|
|
424
|
+
{
|
|
425
|
+
label: "Link",
|
|
426
|
+
icon: Link,
|
|
427
|
+
disabled: !openLinkPanel(state),
|
|
428
|
+
onRun: () => run(openLinkPanel)
|
|
429
|
+
}
|
|
430
|
+
),
|
|
431
|
+
/* @__PURE__ */ jsx(
|
|
432
|
+
ToolbarButton,
|
|
433
|
+
{
|
|
434
|
+
label: commentsOpen ? "Hide comments" : "Show comments",
|
|
435
|
+
icon: MessagesSquare,
|
|
436
|
+
pressed: commentsOpen,
|
|
437
|
+
disabled: !onToggleComments,
|
|
438
|
+
onRun: () => onToggleComments?.()
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
] })
|
|
442
|
+
]
|
|
443
|
+
}
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
export {
|
|
447
|
+
Toolbar
|
|
448
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** A toolbar button whose pointer activation preserves the editor selection and IME state. */
|
|
2
|
+
import type { LucideIcon } from "lucide-react";
|
|
3
|
+
export declare const ICON_SIZE = 16;
|
|
4
|
+
/** Keyboard-generated clicks have `detail === 0`; panels use the source to decide focus. */
|
|
5
|
+
export type RunSource = "pointer" | "keyboard";
|
|
6
|
+
export interface ToolbarButtonProps {
|
|
7
|
+
/** Shared accessible name and tooltip text. */
|
|
8
|
+
label: string;
|
|
9
|
+
icon: LucideIcon;
|
|
10
|
+
pressed?: boolean;
|
|
11
|
+
/** Open state for disclosure buttons. */
|
|
12
|
+
expanded?: boolean;
|
|
13
|
+
popup?: "menu" | "dialog";
|
|
14
|
+
/** Optional color bar drawn under the icon. */
|
|
15
|
+
indicatorColor?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
onRun: (source: RunSource) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `forwardRef` rather than a `ref` prop: React 18 hands a function component no `ref`
|
|
21
|
+
* in its props, so the button would never reach the popovers that focus it.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ToolbarButton: import("react").ForwardRefExoticComponent<ToolbarButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/ui/ToolbarButton.tsx
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { editorClassNames } from "../styles/classNames.js";
|
|
4
|
+
import { tooltipAttribute } from "./Tooltip.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var ICON_SIZE = 16;
|
|
7
|
+
var ToolbarButton = forwardRef(
|
|
8
|
+
function ToolbarButton2({
|
|
9
|
+
label,
|
|
10
|
+
icon: Icon,
|
|
11
|
+
pressed,
|
|
12
|
+
expanded,
|
|
13
|
+
popup,
|
|
14
|
+
indicatorColor,
|
|
15
|
+
disabled,
|
|
16
|
+
onRun
|
|
17
|
+
}, ref) {
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
"button",
|
|
20
|
+
{
|
|
21
|
+
ref,
|
|
22
|
+
type: "button",
|
|
23
|
+
className: editorClassNames.toolbarButton,
|
|
24
|
+
"aria-label": label,
|
|
25
|
+
...tooltipAttribute(label),
|
|
26
|
+
"aria-pressed": pressed,
|
|
27
|
+
"aria-expanded": expanded,
|
|
28
|
+
"aria-haspopup": popup,
|
|
29
|
+
disabled,
|
|
30
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
31
|
+
onClick: (event) => onRun(event.detail > 0 ? "pointer" : "keyboard"),
|
|
32
|
+
children: indicatorColor ? /* @__PURE__ */ jsxs(
|
|
33
|
+
"span",
|
|
34
|
+
{
|
|
35
|
+
className: editorClassNames.toolbarColorIcon,
|
|
36
|
+
"aria-hidden": "true",
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsx(Icon, { size: ICON_SIZE }),
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
"span",
|
|
41
|
+
{
|
|
42
|
+
className: editorClassNames.toolbarColorIndicator,
|
|
43
|
+
style: { backgroundColor: indicatorColor }
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
) : /* @__PURE__ */ jsx(Icon, { size: ICON_SIZE, "aria-hidden": "true" })
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
export {
|
|
54
|
+
ICON_SIZE,
|
|
55
|
+
ToolbarButton
|
|
56
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** CSS-rendered tooltip shown on hover or keyboard focus. */
|
|
2
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
3
|
+
/** Adds tooltip text to an element that can render its own pseudo-element. */
|
|
4
|
+
export declare function tooltipAttribute(label: string): {
|
|
5
|
+
"data-docx-editor-tooltip": string;
|
|
6
|
+
};
|
|
7
|
+
/** Hides tooltips after Escape until pointer or focus movement, as required by WCAG 1.4.13. */
|
|
8
|
+
export declare function useTooltipsHushed(): boolean;
|
|
9
|
+
export declare function hushedAttribute(hushed: boolean): {
|
|
10
|
+
"data-docx-editor-tooltips-off": string;
|
|
11
|
+
} | {
|
|
12
|
+
"data-docx-editor-tooltips-off"?: undefined;
|
|
13
|
+
};
|
|
14
|
+
export interface TooltipProps {
|
|
15
|
+
/** Text shown by the tooltip. */
|
|
16
|
+
label: string;
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare function Tooltip({ label, children }: TooltipProps): ReactElement;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/ui/Tooltip.tsx
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { editorAttributes, editorClassNames } from "../styles/classNames.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
function tooltipAttribute(label) {
|
|
6
|
+
return { [editorAttributes.tooltip]: label };
|
|
7
|
+
}
|
|
8
|
+
function useTooltipsHushed() {
|
|
9
|
+
const [hushed, setHushed] = useState(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const onKeyDown = (event) => {
|
|
12
|
+
if (event.key === "Escape") setHushed(true);
|
|
13
|
+
};
|
|
14
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
15
|
+
return () => document.removeEventListener("keydown", onKeyDown, true);
|
|
16
|
+
}, []);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!hushed) return;
|
|
19
|
+
const wake = () => setHushed(false);
|
|
20
|
+
document.addEventListener("pointermove", wake, true);
|
|
21
|
+
document.addEventListener("focusin", wake, true);
|
|
22
|
+
return () => {
|
|
23
|
+
document.removeEventListener("pointermove", wake, true);
|
|
24
|
+
document.removeEventListener("focusin", wake, true);
|
|
25
|
+
};
|
|
26
|
+
}, [hushed]);
|
|
27
|
+
return hushed;
|
|
28
|
+
}
|
|
29
|
+
function hushedAttribute(hushed) {
|
|
30
|
+
return hushed ? { [editorAttributes.tooltipsHushed]: "" } : {};
|
|
31
|
+
}
|
|
32
|
+
function Tooltip({ label, children }) {
|
|
33
|
+
return /* @__PURE__ */ jsx(
|
|
34
|
+
"span",
|
|
35
|
+
{
|
|
36
|
+
className: editorClassNames.tooltipWrapper,
|
|
37
|
+
...tooltipAttribute(label),
|
|
38
|
+
children
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
Tooltip,
|
|
44
|
+
hushedAttribute,
|
|
45
|
+
tooltipAttribute,
|
|
46
|
+
useTooltipsHushed
|
|
47
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import { type DocxEditorZoom } from "./zoom";
|
|
3
|
+
export interface ZoomSelectProps {
|
|
4
|
+
zoom: DocxEditorZoom;
|
|
5
|
+
onZoomChange: (zoom: DocxEditorZoom) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function ZoomSelect({ zoom, onZoomChange, }: ZoomSelectProps): ReactElement;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// src/ui/ZoomSelect.tsx
|
|
2
|
+
import { editorClassNames } from "../styles/classNames.js";
|
|
3
|
+
import { Tooltip } from "./Tooltip.js";
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_ZOOM_LEVELS,
|
|
6
|
+
normalizeZoom
|
|
7
|
+
} from "./zoom.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
function optionValue(zoom) {
|
|
10
|
+
return zoom === "fit-width" ? zoom : String(zoom);
|
|
11
|
+
}
|
|
12
|
+
function percentage(zoom) {
|
|
13
|
+
return `${Math.round(zoom * 100)}%`;
|
|
14
|
+
}
|
|
15
|
+
function ZoomSelect({
|
|
16
|
+
zoom,
|
|
17
|
+
onZoomChange
|
|
18
|
+
}) {
|
|
19
|
+
const normalized = normalizeZoom(zoom);
|
|
20
|
+
const levels = typeof normalized === "number" && !DEFAULT_ZOOM_LEVELS.includes(
|
|
21
|
+
normalized
|
|
22
|
+
) ? [...DEFAULT_ZOOM_LEVELS, normalized].sort((left, right) => left - right) : DEFAULT_ZOOM_LEVELS;
|
|
23
|
+
return /* @__PURE__ */ jsx(Tooltip, { label: "Zoom", children: /* @__PURE__ */ jsxs(
|
|
24
|
+
"select",
|
|
25
|
+
{
|
|
26
|
+
className: `${editorClassNames.toolbarSelect} ${editorClassNames.zoomSelect}`,
|
|
27
|
+
"aria-label": "Zoom",
|
|
28
|
+
value: optionValue(normalized),
|
|
29
|
+
onChange: (event) => {
|
|
30
|
+
const value = event.currentTarget.value;
|
|
31
|
+
onZoomChange(
|
|
32
|
+
value === "fit-width" ? value : normalizeZoom(Number(value))
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ jsx("option", { value: "fit-width", children: "Fit" }),
|
|
37
|
+
levels.map((level) => /* @__PURE__ */ jsx("option", { value: level, children: percentage(level) }, level))
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
) });
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
ZoomSelect
|
|
44
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import type { CommentAuthor } from "../../editor/commands/commentCommands";
|
|
3
|
+
interface FocusedTextareaProps {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
onChange: (value: string) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function FocusedTextarea({ label, value, onChange, }: FocusedTextareaProps): ReactElement;
|
|
9
|
+
export interface CommentComposerProps {
|
|
10
|
+
author: CommentAuthor;
|
|
11
|
+
label: string;
|
|
12
|
+
submitLabel: string;
|
|
13
|
+
onSubmit: (text: string) => boolean;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function CommentComposer({ author, label, submitLabel, onSubmit, onClose, }: CommentComposerProps): ReactElement;
|
|
17
|
+
export {};
|