@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,208 @@
|
|
|
1
|
+
// src/styles/classNames.ts
|
|
2
|
+
var PREFIX = "docx-editor";
|
|
3
|
+
var editorClassNames = {
|
|
4
|
+
/** The outermost box holding both the toolbar and the paper */
|
|
5
|
+
frame: `${PREFIX}-frame`,
|
|
6
|
+
/** The box that owns the scrolling */
|
|
7
|
+
root: `${PREFIX}-editor`,
|
|
8
|
+
/** The paper the text sits on (contenteditable) */
|
|
9
|
+
sheet: `${PREFIX}-sheet`,
|
|
10
|
+
paragraph: `${PREFIX}-p`,
|
|
11
|
+
run: `${PREFIX}-run`,
|
|
12
|
+
tab: `${PREFIX}-tab`,
|
|
13
|
+
/** The independently measurable DOM range around one tab character. */
|
|
14
|
+
tabSlot: `${PREFIX}-tab-slot`,
|
|
15
|
+
/** The caret drawn at an unambiguous edge of a laid-out tab. */
|
|
16
|
+
tabCaret: `${PREFIX}-tab-caret`,
|
|
17
|
+
/** Attached to the contenteditable while its native caret is replaced. */
|
|
18
|
+
tabCaretActive: `${PREFIX}-tab-caret-active`,
|
|
19
|
+
/** An inline image (`w:drawing` holding a picture) */
|
|
20
|
+
image: `${PREFIX}-img`,
|
|
21
|
+
/** The box the image sits in, which is also what the resize handles stand in */
|
|
22
|
+
imageBox: `${PREFIX}-img-box`,
|
|
23
|
+
/** Attached to that box while the image is the selection */
|
|
24
|
+
imageSelected: `${PREFIX}-img-selected`,
|
|
25
|
+
/** One of the four corner handles a selected image is resized by */
|
|
26
|
+
imageHandle: `${PREFIX}-img-handle`,
|
|
27
|
+
table: `${PREFIX}-tbl`,
|
|
28
|
+
tableRow: `${PREFIX}-tr`,
|
|
29
|
+
tableCell: `${PREFIX}-tc`,
|
|
30
|
+
/** Attached alongside it when the control around the cell says the cell may not be edited */
|
|
31
|
+
cellLocked: `${PREFIX}-tc-locked`,
|
|
32
|
+
/** A stretch of text sitting inside a content control (`w:sdt`) */
|
|
33
|
+
sdt: `${PREFIX}-sdt`,
|
|
34
|
+
/** Attached alongside it when the control says its contents may not be edited */
|
|
35
|
+
sdtLocked: `${PREFIX}-sdt-locked`,
|
|
36
|
+
/** A stretch of text inside a hyperlink (`w:hyperlink`) */
|
|
37
|
+
link: `${PREFIX}-link`,
|
|
38
|
+
/** A stretch of text carrying a comment anchor */
|
|
39
|
+
commentRange: `${PREFIX}-comment-range`,
|
|
40
|
+
/** An invisible OOXML comment marker inside the editable text flow */
|
|
41
|
+
commentMarker: `${PREFIX}-comment-marker`,
|
|
42
|
+
/** A superscript footnote or endnote reference */
|
|
43
|
+
noteReference: `${PREFIX}-note-reference`,
|
|
44
|
+
/** An invisible bookmark marker that occurs between body blocks */
|
|
45
|
+
bookmarkBlock: `${PREFIX}-bookmark-block`,
|
|
46
|
+
rawInline: `${PREFIX}-raw-inline`,
|
|
47
|
+
rawBlock: `${PREFIX}-raw-block`,
|
|
48
|
+
/** A preserved block that carries the original XML directly (inside a table cell, and so on) */
|
|
49
|
+
rawXmlBlock: `${PREFIX}-raw-xml`,
|
|
50
|
+
tablePlaceholder: `${PREFIX}-table`,
|
|
51
|
+
/** The box holding both the paper and the marks overlaid on it */
|
|
52
|
+
pageLayer: `${PREFIX}-page-layer`,
|
|
53
|
+
/** All of the page marks drawn over the paper */
|
|
54
|
+
pageGuides: `${PREFIX}-page-guides`,
|
|
55
|
+
/** The band that covers the space between one page and the next */
|
|
56
|
+
pageSplit: `${PREFIX}-page-split`,
|
|
57
|
+
/** The line drawn where a block that cannot be pushed down crosses a page */
|
|
58
|
+
pageCrossed: `${PREFIX}-page-crossed`,
|
|
59
|
+
/** The page number laid on the top corner of a page */
|
|
60
|
+
pageBadge: `${PREFIX}-page-badge`,
|
|
61
|
+
/** A first-section header story projected into a visual page margin */
|
|
62
|
+
pageHeader: `${PREFIX}-page-header`,
|
|
63
|
+
/** A first-section footer story projected into a visual page margin */
|
|
64
|
+
pageFooter: `${PREFIX}-page-footer`,
|
|
65
|
+
/** The mark that changes the cursor while it is over a column boundary or while a boundary is being dragged. Attached to the sheet */
|
|
66
|
+
columnResize: `${PREFIX}-col-resize`,
|
|
67
|
+
/** The vertical line that shows where the boundary stands while it is being dragged */
|
|
68
|
+
columnResizeGuide: `${PREFIX}-col-guide`,
|
|
69
|
+
rowResize: `${PREFIX}-row-resize`,
|
|
70
|
+
rowResizeGuide: `${PREFIX}-row-guide`,
|
|
71
|
+
/* The controls that come with the editor */
|
|
72
|
+
toolbar: `${PREFIX}-toolbar`,
|
|
73
|
+
/** A bundle of buttons set off by a single separator */
|
|
74
|
+
toolbarGroup: `${PREFIX}-toolbar-group`,
|
|
75
|
+
toolbarSeparator: `${PREFIX}-toolbar-sep`,
|
|
76
|
+
toolbarButton: `${PREFIX}-toolbar-btn`,
|
|
77
|
+
toolbarColorIcon: `${PREFIX}-toolbar-color-icon`,
|
|
78
|
+
toolbarColorIndicator: `${PREFIX}-toolbar-color-indicator`,
|
|
79
|
+
toolbarSelect: `${PREFIX}-toolbar-select`,
|
|
80
|
+
fontFamilySelect: `${PREFIX}-font-family-select`,
|
|
81
|
+
zoomSelect: `${PREFIX}-zoom-select`,
|
|
82
|
+
/** The box wrapped around a control that cannot draw its own tooltip (a native `select`) */
|
|
83
|
+
tooltipWrapper: `${PREFIX}-tooltip-wrap`,
|
|
84
|
+
/** The box around the button a panel opens from. A click inside it counts as a click on the panel */
|
|
85
|
+
popoverBox: `${PREFIX}-popover-box`,
|
|
86
|
+
/** The small panel that opens below a button, floated against the screen */
|
|
87
|
+
popover: `${PREFIX}-popover`,
|
|
88
|
+
/** The grid for picking a table size */
|
|
89
|
+
sizeGrid: `${PREFIX}-size-grid`,
|
|
90
|
+
sizeGridRow: `${PREFIX}-size-row`,
|
|
91
|
+
sizeGridCell: `${PREFIX}-size-cell`,
|
|
92
|
+
sizeGridLabel: `${PREFIX}-size-label`,
|
|
93
|
+
colorPicker: `${PREFIX}-color-picker`,
|
|
94
|
+
/** The text color palette. A grid of rows, so the markup says what the layout shows */
|
|
95
|
+
colorGrid: `${PREFIX}-color-grid`,
|
|
96
|
+
/** One row of the palette. Ten swatches of a family, light to dark */
|
|
97
|
+
colorRow: `${PREFIX}-color-row`,
|
|
98
|
+
/** The row at the head of the palette holding the entry that withdraws the color */
|
|
99
|
+
colorClearRow: `${PREFIX}-color-clear-row`,
|
|
100
|
+
swatch: `${PREFIX}-swatch`,
|
|
101
|
+
colorCustom: `${PREFIX}-color-custom`,
|
|
102
|
+
colorNativeInput: `${PREFIX}-color-native-input`,
|
|
103
|
+
colorHexInput: `${PREFIX}-color-hex-input`,
|
|
104
|
+
colorApply: `${PREFIX}-color-apply`,
|
|
105
|
+
/** The table menu opened with the right button, and the choice menus inside the toolbar panels */
|
|
106
|
+
menu: `${PREFIX}-menu`,
|
|
107
|
+
/** A menu of choices inside a toolbar panel, where one of them is the current one */
|
|
108
|
+
menuList: `${PREFIX}-menu-list`,
|
|
109
|
+
menuItem: `${PREFIX}-menu-item`,
|
|
110
|
+
/** The slot at the head of a menu row where the check mark of the current choice goes */
|
|
111
|
+
menuCheck: `${PREFIX}-menu-check`,
|
|
112
|
+
/** The keyboard shortcut written on the right of a menu row */
|
|
113
|
+
menuHint: `${PREFIX}-menu-hint`,
|
|
114
|
+
menuSeparator: `${PREFIX}-menu-sep`,
|
|
115
|
+
/** The panel that reads and writes a link's address, floated over the selection */
|
|
116
|
+
linkPanel: `${PREFIX}-link-panel`,
|
|
117
|
+
/** The field the address is typed into */
|
|
118
|
+
linkAddress: `${PREFIX}-link-address`,
|
|
119
|
+
/** The row of buttons under it */
|
|
120
|
+
linkPanelRow: `${PREFIX}-link-row`,
|
|
121
|
+
linkPanelIcon: `${PREFIX}-link-icon`,
|
|
122
|
+
/** A button of that panel, and of the card below, which offer the same actions */
|
|
123
|
+
/** The card that says where the link under the cursor points, floated under the link's first line */
|
|
124
|
+
linkCard: `${PREFIX}-link-card`,
|
|
125
|
+
/** The address it shows, cut off with an ellipsis where it is longer than the card */
|
|
126
|
+
linkCardAddress: `${PREFIX}-link-card-address`,
|
|
127
|
+
/** What it says in place of an address for a link that names a place in the document */
|
|
128
|
+
linkCardNote: `${PREFIX}-link-card-note`,
|
|
129
|
+
/** The document and its comment rail, laid out side by side */
|
|
130
|
+
workspace: `${PREFIX}-workspace`,
|
|
131
|
+
commentsPanel: `${PREFIX}-comments`,
|
|
132
|
+
commentsToggle: `${PREFIX}-comments-toggle`,
|
|
133
|
+
commentsHeading: `${PREFIX}-comments-heading`,
|
|
134
|
+
commentsCanvas: `${PREFIX}-comments-canvas`,
|
|
135
|
+
commentsEmpty: `${PREFIX}-comments-empty`,
|
|
136
|
+
commentPosition: `${PREFIX}-comment-position`,
|
|
137
|
+
commentCard: `${PREFIX}-comment-card`,
|
|
138
|
+
commentHeader: `${PREFIX}-comment-header`,
|
|
139
|
+
commentReply: `${PREFIX}-comment-reply`,
|
|
140
|
+
commentMeta: `${PREFIX}-comment-meta`,
|
|
141
|
+
commentAuthor: `${PREFIX}-comment-author`,
|
|
142
|
+
commentDate: `${PREFIX}-comment-date`,
|
|
143
|
+
commentBody: `${PREFIX}-comment-body`,
|
|
144
|
+
commentActions: `${PREFIX}-comment-actions`,
|
|
145
|
+
commentPrimaryAction: `${PREFIX}-comment-primary-action`,
|
|
146
|
+
commentIconActions: `${PREFIX}-comment-icon-actions`,
|
|
147
|
+
commentComposer: `${PREFIX}-comment-composer`,
|
|
148
|
+
commentInput: `${PREFIX}-comment-input`,
|
|
149
|
+
notesPanel: `${PREFIX}-notes`,
|
|
150
|
+
notesHeading: `${PREFIX}-notes-heading`,
|
|
151
|
+
notesList: `${PREFIX}-notes-list`,
|
|
152
|
+
noteLabel: `${PREFIX}-note-label`,
|
|
153
|
+
noteBody: `${PREFIX}-note-body`,
|
|
154
|
+
/** The panel drawn in place of the editor when a document was refused and the consumer wrote no panel of its own */
|
|
155
|
+
rejection: `${PREFIX}-rejection`,
|
|
156
|
+
rejectionTitle: `${PREFIX}-rejection-title`
|
|
157
|
+
};
|
|
158
|
+
var editorCssVariables = {
|
|
159
|
+
fontSize: `--${PREFIX}-font-size`,
|
|
160
|
+
fontFamily: `--${PREFIX}-font-family`,
|
|
161
|
+
lineHeight: `--${PREFIX}-line-height`,
|
|
162
|
+
/** The hanging indent width the list marker sits in */
|
|
163
|
+
markerWidth: `--${PREFIX}-marker-width`,
|
|
164
|
+
/** The width calculated for a tab using custom paragraph stops. */
|
|
165
|
+
tabWidth: `--${PREFIX}-tab-width`,
|
|
166
|
+
/** The paper height, grown to match the page count */
|
|
167
|
+
sheetHeight: `--${PREFIX}-sheet-height`,
|
|
168
|
+
/** The paper the open document names, and the margins printed inside it */
|
|
169
|
+
pageWidth: `--${PREFIX}-page-width`,
|
|
170
|
+
pageHeight: `--${PREFIX}-page-height`,
|
|
171
|
+
pageMarginTop: `--${PREFIX}-page-margin-top`,
|
|
172
|
+
pageMarginRight: `--${PREFIX}-page-margin-right`,
|
|
173
|
+
pageMarginBottom: `--${PREFIX}-page-margin-bottom`,
|
|
174
|
+
pageMarginLeft: `--${PREFIX}-page-margin-left`
|
|
175
|
+
};
|
|
176
|
+
var editorAttributes = {
|
|
177
|
+
listMarker: "data-marker",
|
|
178
|
+
/** A new page starts at this paragraph */
|
|
179
|
+
pageBreakBefore: "data-page-break",
|
|
180
|
+
/** The kind of line break. `page` when the break splits the page */
|
|
181
|
+
breakType: "data-break",
|
|
182
|
+
/** Which corner of the image a resize handle stands at (`nw`, `ne`, `sw`, `se`) */
|
|
183
|
+
imageCorner: "data-corner",
|
|
184
|
+
/** The extra height opened up to push content down to the top of the next page */
|
|
185
|
+
pagePush: "data-page-push",
|
|
186
|
+
/** The space opened up at a page break, so what follows the break starts the next page */
|
|
187
|
+
pageBreakSpace: "data-page-space",
|
|
188
|
+
/** A display-only table row that fills the remainder between page bodies */
|
|
189
|
+
tablePageSpace: "data-table-page-space",
|
|
190
|
+
/** A display-only copy of a table header row on a continued page */
|
|
191
|
+
tableRepeatedHeader: "data-table-repeated-header",
|
|
192
|
+
/**
|
|
193
|
+
* The tooltip a control shows on hover, drawn by the CSS straight from this attribute.
|
|
194
|
+
* It is the one mark here whose selector is the attribute on its own rather than a
|
|
195
|
+
* class of ours, so it carries the prefix and cannot collide with the host app.
|
|
196
|
+
*/
|
|
197
|
+
tooltip: `data-${PREFIX}-tooltip`,
|
|
198
|
+
/**
|
|
199
|
+
* Put on the box the tooltips are drawn inside while they are hushed, which is what Escape
|
|
200
|
+
* does to the one standing in the way (`ui/Tooltip.tsx`).
|
|
201
|
+
*/
|
|
202
|
+
tooltipsHushed: `data-${PREFIX}-tooltips-off`
|
|
203
|
+
};
|
|
204
|
+
export {
|
|
205
|
+
editorAttributes,
|
|
206
|
+
editorClassNames,
|
|
207
|
+
editorCssVariables
|
|
208
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colors the built-in pickers offer, the same set for text, for text background and for the
|
|
3
|
+
* lines and the fill of a table cell.
|
|
4
|
+
*
|
|
5
|
+
* The swatches are the standard Google Docs palette, written exactly as it is laid out on
|
|
6
|
+
* screen: ten colors to a row, the neutrals first and the pure hues after them, and from the
|
|
7
|
+
* third row down each column holds one family descending from light to dark.
|
|
8
|
+
*/
|
|
9
|
+
/** One row of the grid a color picker draws, holding that row's `#rrggbb` colors */
|
|
10
|
+
export type ColorRow = readonly string[];
|
|
11
|
+
export declare const DEFAULT_COLORS: readonly ColorRow[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/styles/colors.ts
|
|
2
|
+
var DEFAULT_COLORS = [
|
|
3
|
+
"000000 434343 666666 999999 b7b7b7 cccccc d9d9d9 efefef f3f3f3 ffffff",
|
|
4
|
+
"980000 ff0000 ff9900 ffff00 00ff00 00ffff 4a86e8 0000ff 9900ff ff00ff",
|
|
5
|
+
"e6b8af f4cccc fce5cd fff2cc d9ead3 d0e0e3 c9daf8 cfe2f3 d9d2e9 ead1dc",
|
|
6
|
+
"dd7e6b ea9999 f9cb9c ffe599 b6d7a8 a2c4c9 a4c2f4 9fc5e8 b4a7d6 d5a6bd",
|
|
7
|
+
"cc4125 e06666 f6b26b ffd966 93c47d 76a5af 6d9eeb 6fa8dc 8e7cc3 c27ba0",
|
|
8
|
+
"a61c00 cc0000 e69138 f1c232 6aa84f 45818e 3c78d8 3d85c6 674ea7 a64d79",
|
|
9
|
+
"85200c 990000 b45f06 bf9000 38761d 134f5c 1155cc 0b5394 351c75 741b47",
|
|
10
|
+
"5b0f00 660000 783f04 7f6000 274e13 0c343d 1c4587 073763 20124d 4c1130"
|
|
11
|
+
].map((row) => row.split(" ").map((hex) => `#${hex}`));
|
|
12
|
+
export {
|
|
13
|
+
DEFAULT_COLORS
|
|
14
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sizes in points the built-in font size picker offers, which is the set Word offers.
|
|
3
|
+
* A size the open document itself uses is offered along with them whether or not it stands in
|
|
4
|
+
* this list, so nothing a document declares is left unreachable.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_FONT_SIZES: readonly number[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injectable display-only fallback stacks for fonts unavailable on the current platform. The
|
|
3
|
+
* document's declared name remains first and exported `w:rFonts` is never changed.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* One fallback stack and the font names that receive it.
|
|
7
|
+
*
|
|
8
|
+
* A group is a family: every name in it is drawn with the same stand-in font.
|
|
9
|
+
*/
|
|
10
|
+
export interface FontFallbackGroup {
|
|
11
|
+
/** The fonts appended after the declared name, written as a CSS font-family list */
|
|
12
|
+
readonly stack: string;
|
|
13
|
+
/** The font names in this family. Letter case varies from document to document, so matching ignores it */
|
|
14
|
+
readonly names: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
/** The fallback fonts an editor draws with */
|
|
17
|
+
export interface FontFallbacks {
|
|
18
|
+
readonly groups: readonly FontFallbackGroup[];
|
|
19
|
+
/**
|
|
20
|
+
* The stack for a name in no group, and the stack laid across the whole paper
|
|
21
|
+
* when the document declares no font at all.
|
|
22
|
+
*/
|
|
23
|
+
readonly defaultStack: string;
|
|
24
|
+
/**
|
|
25
|
+
* The font name the toolbar shows for a document that declares none.
|
|
26
|
+
* It has to be the font `defaultStack` actually renders, since that is what the
|
|
27
|
+
* reader sees.
|
|
28
|
+
*/
|
|
29
|
+
readonly defaultFontName: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The built-in set: the CJK and Latin families above, and a Latin default.
|
|
33
|
+
*
|
|
34
|
+
* An unrecognized name, and a document that declares no font at all, land on a
|
|
35
|
+
* Latin sans. A screen serving documents in a particular language hands in its
|
|
36
|
+
* own set (`fontFallbacks` on `DocxEditor`).
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEFAULT_FONT_FALLBACKS: FontFallbacks;
|
|
39
|
+
/**
|
|
40
|
+
* Whether this font name belongs to a script written in Han characters, kana or
|
|
41
|
+
* Hangul.
|
|
42
|
+
*
|
|
43
|
+
* It decides which `w:rFonts` slots a font applies to, so it reads the built-in
|
|
44
|
+
* families rather than the fallback set the consumer handed in: which fonts stand in
|
|
45
|
+
* for which names on screen must not change what is written into the document.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isEastAsianFontName(name: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Appends a fallback font of the same family after each name the document declares.
|
|
50
|
+
*
|
|
51
|
+
* A run of a Japanese or Chinese document names a Latin font and an East Asian one
|
|
52
|
+
* both, one per `w:rFonts` slot, and the two belong to different families: each of
|
|
53
|
+
* them needs the stack of its own family behind it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function withFontFallback(cssNames: string, fallbacks?: FontFallbacks): string;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
// src/styles/fontStack.ts
|
|
2
|
+
var KOREAN_GOTHIC = '"Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif';
|
|
3
|
+
var KOREAN_MYEONGJO = '"Noto Serif KR", AppleMyungjo, serif';
|
|
4
|
+
var JAPANESE_GOTHIC = '"Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, "Noto Sans JP", sans-serif';
|
|
5
|
+
var JAPANESE_MINCHO = '"Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif';
|
|
6
|
+
var CHINESE_SIMPLIFIED_SANS = '"PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif';
|
|
7
|
+
var CHINESE_SIMPLIFIED_SERIF = '"Songti SC", "Noto Serif SC", serif';
|
|
8
|
+
var CHINESE_TRADITIONAL_SANS = '"PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif';
|
|
9
|
+
var CHINESE_TRADITIONAL_SERIF = '"Songti TC", "Noto Serif TC", serif';
|
|
10
|
+
var EAST_ASIAN_GROUPS = [
|
|
11
|
+
{
|
|
12
|
+
stack: KOREAN_GOTHIC,
|
|
13
|
+
names: [
|
|
14
|
+
"malgun gothic",
|
|
15
|
+
"\uB9D1\uC740\uACE0\uB515",
|
|
16
|
+
"\uB9D1\uC740 \uACE0\uB515",
|
|
17
|
+
"gulim",
|
|
18
|
+
"gulimche",
|
|
19
|
+
"\uAD74\uB9BC",
|
|
20
|
+
"\uAD74\uB9BC\uCCB4",
|
|
21
|
+
"dotum",
|
|
22
|
+
"dotumche",
|
|
23
|
+
"\uB3CB\uC6C0",
|
|
24
|
+
"\uB3CB\uC6C0\uCCB4",
|
|
25
|
+
"nanum gothic",
|
|
26
|
+
"\uB098\uB214\uACE0\uB515",
|
|
27
|
+
"noto sans kr",
|
|
28
|
+
"apple sd gothic neo",
|
|
29
|
+
"\uD568\uCD08\uB86C\uB3CB\uC6C0"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
stack: KOREAN_MYEONGJO,
|
|
34
|
+
names: [
|
|
35
|
+
"batang",
|
|
36
|
+
"batangche",
|
|
37
|
+
"\uBC14\uD0D5",
|
|
38
|
+
"\uBC14\uD0D5\uCCB4",
|
|
39
|
+
"gungsuh",
|
|
40
|
+
"gungsuhche",
|
|
41
|
+
"\uAD81\uC11C",
|
|
42
|
+
"\uAD81\uC11C\uCCB4",
|
|
43
|
+
"nanum myeongjo",
|
|
44
|
+
"\uB098\uB214\uBA85\uC870",
|
|
45
|
+
"\uBA85\uC870",
|
|
46
|
+
"\uD568\uCD08\uB86C\uBC14\uD0D5"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
stack: JAPANESE_GOTHIC,
|
|
51
|
+
names: [
|
|
52
|
+
"ms gothic",
|
|
53
|
+
"\uFF2D\uFF33 \u30B4\u30B7\u30C3\u30AF",
|
|
54
|
+
"ms pgothic",
|
|
55
|
+
"\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF",
|
|
56
|
+
"ms ui gothic",
|
|
57
|
+
"\uFF2D\uFF33 \uFF35\uFF29 \u30B4\u30B7\u30C3\u30AF",
|
|
58
|
+
"yu gothic",
|
|
59
|
+
"yugothic",
|
|
60
|
+
"\u6E38\u30B4\u30B7\u30C3\u30AF",
|
|
61
|
+
"yu gothic ui",
|
|
62
|
+
"\u6E38\u30B4\u30B7\u30C3\u30AF UI",
|
|
63
|
+
"meiryo",
|
|
64
|
+
"\u30E1\u30A4\u30EA\u30AA",
|
|
65
|
+
"meiryo ui",
|
|
66
|
+
"hiragino kaku gothic pro",
|
|
67
|
+
"hiragino kaku gothic pron",
|
|
68
|
+
"hiragino sans",
|
|
69
|
+
"\u30D2\u30E9\u30AE\u30CE\u89D2\u30B4 Pro W3",
|
|
70
|
+
"\u30D2\u30E9\u30AE\u30CE\u89D2\u30B4 ProN W3",
|
|
71
|
+
"\u30D2\u30E9\u30AE\u30CE\u89D2\u30B4\u30B7\u30C3\u30AF",
|
|
72
|
+
"noto sans jp",
|
|
73
|
+
"biz udgothic",
|
|
74
|
+
"biz udpgothic",
|
|
75
|
+
"BIZ UD\u30B4\u30B7\u30C3\u30AF"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
stack: JAPANESE_MINCHO,
|
|
80
|
+
names: [
|
|
81
|
+
"ms mincho",
|
|
82
|
+
"\uFF2D\uFF33 \u660E\u671D",
|
|
83
|
+
"ms pmincho",
|
|
84
|
+
"\uFF2D\uFF33 \uFF30\u660E\u671D",
|
|
85
|
+
"yu mincho",
|
|
86
|
+
"yumincho",
|
|
87
|
+
"\u6E38\u660E\u671D",
|
|
88
|
+
"hiragino mincho pro",
|
|
89
|
+
"hiragino mincho pron",
|
|
90
|
+
"\u30D2\u30E9\u30AE\u30CE\u660E\u671D Pro W3",
|
|
91
|
+
"\u30D2\u30E9\u30AE\u30CE\u660E\u671D ProN W3",
|
|
92
|
+
"\u30D2\u30E9\u30AE\u30CE\u660E\u671D",
|
|
93
|
+
"noto serif jp",
|
|
94
|
+
"biz udmincho",
|
|
95
|
+
"biz udpmincho",
|
|
96
|
+
"BIZ UD\u660E\u671D"
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
stack: CHINESE_SIMPLIFIED_SANS,
|
|
101
|
+
names: [
|
|
102
|
+
"microsoft yahei",
|
|
103
|
+
"microsoft yahei ui",
|
|
104
|
+
"\u5FAE\u8F6F\u96C5\u9ED1",
|
|
105
|
+
"pingfang sc",
|
|
106
|
+
"\u82F9\u65B9",
|
|
107
|
+
"\u82F9\u65B9-\u7B80",
|
|
108
|
+
"noto sans sc",
|
|
109
|
+
"source han sans sc",
|
|
110
|
+
"simhei",
|
|
111
|
+
"\u9ED1\u4F53",
|
|
112
|
+
"heiti sc",
|
|
113
|
+
"dengxian",
|
|
114
|
+
"\u7B49\u7EBF"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
stack: CHINESE_SIMPLIFIED_SERIF,
|
|
119
|
+
names: [
|
|
120
|
+
"simsun",
|
|
121
|
+
"\u5B8B\u4F53",
|
|
122
|
+
"nsimsun",
|
|
123
|
+
"\u65B0\u5B8B\u4F53",
|
|
124
|
+
"songti sc",
|
|
125
|
+
"fangsong",
|
|
126
|
+
"\u4EFF\u5B8B",
|
|
127
|
+
"kaiti",
|
|
128
|
+
"\u6977\u4F53",
|
|
129
|
+
"noto serif sc",
|
|
130
|
+
"source han serif sc"
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
stack: CHINESE_TRADITIONAL_SANS,
|
|
135
|
+
names: [
|
|
136
|
+
"microsoft jhenghei",
|
|
137
|
+
"microsoft jhenghei ui",
|
|
138
|
+
"\u5FAE\u8EDF\u6B63\u9ED1\u9AD4",
|
|
139
|
+
"pingfang tc",
|
|
140
|
+
"\u860B\u65B9-\u7E41",
|
|
141
|
+
"noto sans tc"
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
stack: CHINESE_TRADITIONAL_SERIF,
|
|
146
|
+
names: [
|
|
147
|
+
"pmingliu",
|
|
148
|
+
"\u65B0\u7D30\u660E\u9AD4",
|
|
149
|
+
"mingliu",
|
|
150
|
+
"\u7D30\u660E\u9AD4",
|
|
151
|
+
"dfkai-sb",
|
|
152
|
+
"\u6A19\u6977\u9AD4",
|
|
153
|
+
"songti tc",
|
|
154
|
+
"noto serif tc"
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
];
|
|
158
|
+
var LATIN_GROUPS = [
|
|
159
|
+
{
|
|
160
|
+
stack: "sans-serif",
|
|
161
|
+
names: [
|
|
162
|
+
"arial",
|
|
163
|
+
"helvetica",
|
|
164
|
+
"verdana",
|
|
165
|
+
"tahoma",
|
|
166
|
+
"trebuchet ms",
|
|
167
|
+
"calibri",
|
|
168
|
+
"segoe ui",
|
|
169
|
+
"roboto",
|
|
170
|
+
"open sans",
|
|
171
|
+
"noto sans"
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
stack: "serif",
|
|
176
|
+
names: [
|
|
177
|
+
"times new roman",
|
|
178
|
+
"georgia",
|
|
179
|
+
"garamond",
|
|
180
|
+
"cambria",
|
|
181
|
+
"book antiqua",
|
|
182
|
+
"palatino linotype"
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
{ stack: "monospace", names: ["courier new", "consolas"] }
|
|
186
|
+
];
|
|
187
|
+
var DEFAULT_FONT_FALLBACKS = {
|
|
188
|
+
groups: [...EAST_ASIAN_GROUPS, ...LATIN_GROUPS],
|
|
189
|
+
defaultStack: "Arial, Helvetica, sans-serif",
|
|
190
|
+
defaultFontName: "Arial"
|
|
191
|
+
};
|
|
192
|
+
function comparableName(name) {
|
|
193
|
+
return name.trim().replace(/^["']|["']$/g, "").toLowerCase();
|
|
194
|
+
}
|
|
195
|
+
var EAST_ASIAN_CHARACTER = /[\u1100-\u11ff\u3000-\u30ff\u3130-\u318f\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9fff\ua960-\ua97f\uac00-\ud7ff\uf900-\ufaff\uff00-\uffef\u{20000}-\u{2fa1f}]/u;
|
|
196
|
+
var eastAsianNames = new Set(
|
|
197
|
+
EAST_ASIAN_GROUPS.flatMap((group) => group.names.map(comparableName))
|
|
198
|
+
);
|
|
199
|
+
function isEastAsianFontName(name) {
|
|
200
|
+
return EAST_ASIAN_CHARACTER.test(name) || eastAsianNames.has(comparableName(name));
|
|
201
|
+
}
|
|
202
|
+
var stacksByFallbacks = /* @__PURE__ */ new WeakMap();
|
|
203
|
+
function stackByName(fallbacks) {
|
|
204
|
+
const built = stacksByFallbacks.get(fallbacks);
|
|
205
|
+
if (built) return built;
|
|
206
|
+
const stacks = /* @__PURE__ */ new Map();
|
|
207
|
+
for (const group of fallbacks.groups) {
|
|
208
|
+
for (const name of group.names)
|
|
209
|
+
stacks.set(comparableName(name), group.stack);
|
|
210
|
+
}
|
|
211
|
+
stacksByFallbacks.set(fallbacks, stacks);
|
|
212
|
+
return stacks;
|
|
213
|
+
}
|
|
214
|
+
function matchedStacks(cssNames, fallbacks) {
|
|
215
|
+
const stacks = stackByName(fallbacks);
|
|
216
|
+
const matched = [];
|
|
217
|
+
for (const name of cssNames.split(",")) {
|
|
218
|
+
const stack = stacks.get(comparableName(name));
|
|
219
|
+
if (stack !== void 0 && !matched.includes(stack)) matched.push(stack);
|
|
220
|
+
}
|
|
221
|
+
return matched;
|
|
222
|
+
}
|
|
223
|
+
var GENERIC_FAMILIES = /* @__PURE__ */ new Set([
|
|
224
|
+
"serif",
|
|
225
|
+
"sans-serif",
|
|
226
|
+
"monospace",
|
|
227
|
+
"cursive",
|
|
228
|
+
"fantasy",
|
|
229
|
+
"system-ui",
|
|
230
|
+
"ui-serif",
|
|
231
|
+
"ui-sans-serif",
|
|
232
|
+
"ui-monospace",
|
|
233
|
+
"ui-rounded",
|
|
234
|
+
"math",
|
|
235
|
+
"emoji"
|
|
236
|
+
]);
|
|
237
|
+
function isGenericFamily(name) {
|
|
238
|
+
return GENERIC_FAMILIES.has(comparableName(name));
|
|
239
|
+
}
|
|
240
|
+
function distinctNames(names) {
|
|
241
|
+
const seen = /* @__PURE__ */ new Set();
|
|
242
|
+
return names.filter((name) => {
|
|
243
|
+
const comparable = comparableName(name);
|
|
244
|
+
if (seen.has(comparable)) return false;
|
|
245
|
+
seen.add(comparable);
|
|
246
|
+
return true;
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function withFontFallback(cssNames, fallbacks = DEFAULT_FONT_FALLBACKS) {
|
|
250
|
+
const matched = matchedStacks(cssNames, fallbacks);
|
|
251
|
+
const appended = (matched.length > 0 ? matched : [fallbacks.defaultStack]).flatMap((stack) => stack.split(","));
|
|
252
|
+
return distinctNames([
|
|
253
|
+
...cssNames.split(","),
|
|
254
|
+
...appended.filter((name) => !isGenericFamily(name)),
|
|
255
|
+
...appended.filter(isGenericFamily)
|
|
256
|
+
]).join(",");
|
|
257
|
+
}
|
|
258
|
+
export {
|
|
259
|
+
DEFAULT_FONT_FALLBACKS,
|
|
260
|
+
isEastAsianFontName,
|
|
261
|
+
withFontFallback
|
|
262
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type CellFormat, type DocumentDefaults, type HighlightName, type LineSpacing, type ParagraphFormat, type RowFormat, type RunFormat, type TableFormat, type TableWidth } from "../model/format";
|
|
2
|
+
import { type FontFallbacks } from "./fontStack";
|
|
3
|
+
/**
|
|
4
|
+
* The value used on screen only, when nowhere in the document declares a default
|
|
5
|
+
* font size.
|
|
6
|
+
* It matches the value Word uses, and it never makes its way back into the document.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FALLBACK_FONT_SIZE_PT = 10;
|
|
9
|
+
/**
|
|
10
|
+
* What Word calls "one line" is not the font size but the line height the font
|
|
11
|
+
* itself declares.
|
|
12
|
+
* On screen that height is approximated as this multiple of the font size.
|
|
13
|
+
* It is also the default for a document that declares no line spacing anywhere.
|
|
14
|
+
*
|
|
15
|
+
* Malgun Gothic, which dominates contracts, has a tall font-declared line box, so
|
|
16
|
+
* Word really does render more loosely.
|
|
17
|
+
* Drawing at 1.2 drew the complaint that it looked denser than the original, so it
|
|
18
|
+
* was raised to 1.3.
|
|
19
|
+
* The same value is also written as the `--docx-editor-line-height` default in
|
|
20
|
+
* `editor.css`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SINGLE_LINE_RATIO = 1.3;
|
|
23
|
+
/**
|
|
24
|
+
* Word highlighter (`w:highlight`) names and the colors they stand for.
|
|
25
|
+
*
|
|
26
|
+
* We write background colors with `w:shd`, but older documents recorded them under
|
|
27
|
+
* these names.
|
|
28
|
+
* Converting the names to colors lets such a document be drawn as the original was
|
|
29
|
+
* and lets the toolbar palette compare against the current color.
|
|
30
|
+
*/
|
|
31
|
+
export declare const HIGHLIGHT_COLORS: Record<HighlightName, string>;
|
|
32
|
+
/** Turns line spacing into a single CSS line-height value. With none given, one line height is the default */
|
|
33
|
+
export declare function lineHeightValue(spacing: LineSpacing | null): string;
|
|
34
|
+
export declare function runStyle(format: RunFormat | null, fontFallbacks?: FontFallbacks): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The CSS a paragraph is drawn with: its own formatting, and the character formatting the style it
|
|
37
|
+
* wears lays down for the text inside it (`styleRun`).
|
|
38
|
+
*
|
|
39
|
+
* Text typed in the editor carries no run of its own, so inheriting from the paragraph is the only
|
|
40
|
+
* way it can be drawn in the style's character formatting. Text that does carry a run declares
|
|
41
|
+
* those same values on itself, and an element's own declaration beats an inherited one, so nothing
|
|
42
|
+
* a run wrote down is disturbed.
|
|
43
|
+
* Only the declarations that carry down are written. A fill paints a box instead of passing down,
|
|
44
|
+
* so on a paragraph it would cover the whole line, and the paragraph's own shading along with it.
|
|
45
|
+
* A style that fills behind its characters is therefore drawn from the run each piece of text
|
|
46
|
+
* carries, and not from here.
|
|
47
|
+
* The fonts stood in for the ones the style names are the built-in ones, because unlike a run
|
|
48
|
+
* (`editor/runMarkView`) a paragraph is drawn by the schema alone, which cannot see which editor it
|
|
49
|
+
* is drawing for.
|
|
50
|
+
*/
|
|
51
|
+
export declare function paragraphStyle(format: ParagraphFormat | null, styleRun?: RunFormat | null): string | undefined;
|
|
52
|
+
export declare function columnWidthPx(dxa: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* The table itself draws no line at all: every line of a table, the ones around the outside included,
|
|
55
|
+
* is drawn by its cells. A border on the table element would win over a cell that says to draw
|
|
56
|
+
* nothing, because CSS resolves a collapsed border in favour of the solid line.
|
|
57
|
+
*/
|
|
58
|
+
export declare function tableStyle(format: TableFormat | null, width: TableWidth | null): string | undefined;
|
|
59
|
+
/** CSS treats a row's height as a floor whichever rule the document wrote, so both are drawn alike */
|
|
60
|
+
export declare function rowStyle(format: RowFormat | null): string | undefined;
|
|
61
|
+
export declare function cellStyle(format: CellFormat | null): string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Turns the document defaults into CSS variables that apply across the whole paper.
|
|
64
|
+
* A font is always settled on, even when the document declares none, so that it is
|
|
65
|
+
* not drawn in a different font in every environment.
|
|
66
|
+
*/
|
|
67
|
+
export declare function documentDefaultsStyle(defaults: DocumentDefaults, fontFallbacks?: FontFallbacks): string;
|