ooxml-ui 1.32.0 → 1.33.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/custom-elements.json +10 -0
- package/dist/building-block-styles.d.ts +1 -0
- package/dist/chart/format-pane-3d.d.ts +1 -0
- package/dist/chart/format-pane-analysis.d.ts +1 -0
- package/dist/chart/format-pane-fill-line.d.ts +1 -0
- package/dist/chart/format-pane-text.d.ts +1 -0
- package/dist/{chunk-32P252JS.js → chunk-QK5DQR6L.js} +1 -1
- package/dist/{chunk-WYKMVMX4.js → chunk-VSHQNHDG.js} +40 -0
- package/dist/{chunk-OKEFAQJT.js → chunk-XPUXFZNB.js} +71 -18
- package/dist/docx/editor-attributes.d.ts +7 -0
- package/dist/docx/format-dialogs.d.ts +1 -1
- package/dist/docx/locales/en.d.ts +4 -0
- package/dist/docx/locales/split-cells.d.ts +10 -0
- package/dist/docx/localization-strings.d.ts +4 -0
- package/dist/docx/ribbon-icons.d.ts +2 -0
- package/dist/docx/split-cells-dialog.d.ts +4 -0
- package/dist/docx/table-commands.d.ts +9 -3
- package/dist/docx/table-model-adapter.d.ts +5 -0
- package/dist/docx/table-restructure-commands.d.ts +36 -0
- package/dist/docx/table-restructure-convert.d.ts +10 -0
- package/dist/docx/table-restructure.d.ts +22 -0
- package/dist/docx.js +652 -46
- package/dist/index.js +3 -3
- package/dist/{presentation-preview-XGJMARKI.js → presentation-preview-DKJC6TUJ.js} +1 -1
- package/dist/teams/app/chat-people-dialog.d.ts +5 -0
- package/dist/teams/app/teams-app.d.ts +3 -0
- package/dist/teams/chat-list.d.ts +5 -0
- package/dist/teams/i18n/locales/de.d.ts +8 -0
- package/dist/teams/i18n/locales/en/chat.d.ts +2 -0
- package/dist/teams/i18n/locales/en/shell.d.ts +6 -0
- package/dist/teams/i18n/locales/en.d.ts +8 -0
- package/dist/teams/i18n/locales/es.d.ts +8 -0
- package/dist/teams/i18n/locales/fr.d.ts +8 -0
- package/dist/teams/i18n/locales/zh-CN.d.ts +8 -0
- package/dist/teams.js +2 -2
- package/dist/theme-bridge.d.ts +1 -0
- package/dist/theme.d.ts +1 -0
- package/dist/xlsx/dialogs/custom-views.d.ts +2 -0
- package/dist/xlsx/dialogs/forecast-sheet.d.ts +2 -0
- package/dist/xlsx/dialogs/scenario-extras.d.ts +8 -0
- package/dist/xlsx/grid/shapes.d.ts +21 -0
- package/dist/xlsx/grid/styles.d.ts +1 -1
- package/dist/xlsx/header-image.d.ts +8 -0
- package/dist/xlsx.js +656 -126
- package/package.json +2 -2
package/dist/docx.js
CHANGED
|
@@ -12,7 +12,7 @@ import './chunk-QLHCGV4C.js';
|
|
|
12
12
|
import './chunk-XL77FR4B.js';
|
|
13
13
|
import { optionStrings, normalizeLocale, SUPPORTED_OFFICE_LOCALES, interpolate } from 'ooxml-core/i18n';
|
|
14
14
|
import { DIAGRAM_UI_STRINGS, DIAGRAM_ADD_SHAPE_COMMANDS, DEFAULT_GENERATED_DIAGRAM_SCHEME, DIAGRAM_DESIGN_GROUPS, DIAGRAM_INSERT_PRESETS, DIAGRAM_DESIGN_COMMANDS, DIAGRAM_COLOR_ENTRIES, DIAGRAM_STYLE_ENTRIES, DIAGRAM_INSERT_CATEGORIES, DIAGRAM_ADD_SHAPE_LABEL } from 'ooxml-core/diagram';
|
|
15
|
-
import { markSpecs, imageNodeSpec, fieldMarkerNodeSpec, noteReferenceNodeSpec, pageBreakNodeSpec, hardBreakNodeSpec, commentHistoryAttributes, tableCellStyle, tableStyle, createToggleFormat, expectDefined, controlFromData, paragraphBoxCss, WORD_CAPABILITY_ACTIONS, normalizeThemeMode, applyThemeColors, refreshWordYjsPresence, normalizeRibbonActions, DirtyState, isFormsProtected, isWordYjsRemoteTransaction, REMOTE_TRANSACTION_META, repairCollaborativeDocumentIds, HEADER_FOOTER_INPUT, wordYjsPluginKey, wordYjsRedo, wordYjsUndo, documentWordCount, restoreSectionParts, commentThreadsFromDoc, restoreNoteParts, CollaborationClient, createCollaborationIdGenerator, WordYjsCollaboration, insertContentControl, sectionPartsJson, NotePartsStep, notePartsJson, SectionPartsStep, fitZoomPercent, hasChangeAtCursor, hasAnyChange, commentIdsAtSelection, commentAnchors, fieldGuardPlugin, tableStructureGuardPlugin, contentControlPlugin, formFieldGuardPlugin, symbolFontPlugin, positionalTabInputPlugin, trackChangesPlugin, wordYjsPresencePlugin, placementClass, removeCommentThread, removeCommentAnchor, deleteComment, updateCommentThreads, addComment, toggleTrackChanges, goToNextChange, goToPreviousChange, rejectAllChanges, acceptAllChanges, rejectChangeAtCursor, acceptChangeAtCursor, goToComment, selectedChart, appendInlineNode, sameJson, sameRuns, PARAGRAPH_KEEP_KEYS, paragraphFromAttrs, parseBordersJson, isNavigableHref, setReviewRecordingPreferences, insertChartImage, nodeNumbering, controlAtSelection, paragraphFormattingRevision, inlineNodeRun, formattingRevision, insertWordHardBreak, paragraphAttrs, resolveCellVisuals, previewDocxDiagram, themeDrawing, chartNodeSpec, replaceSelectedChart, ribbonActionIdForLabel, removeWordLink, fieldResultRanges, wordLinkRangeAt, ligatureCss as ligatureCss$1, toggleCheckboxControl, formFieldBeside, formFieldOfNode, formFieldLocked, toggleFormCheckboxAt, runToInlineNodes as runToInlineNodes$1, insertedTextMarks, backstageFocus, applyRunFormattingPatch, clearDirectRunFormatting, applyWordLink, deleteFieldSelection, emptySimpleFieldResult, ligatureStyle, wordHighlightColors, swatchColor, cssBorderSide, countWords, chooseListItem, chooseDate, selectFormDropDownAt, updateControlProperties, WORD_CAPABILITY_MENU_ITEMS, WORD_CAPABILITY_SHORTCUTS, WORD_CAPABILITY_BACKSTAGE_PAGES, WORD_CAPABILITY_FILE_COMMANDS, resolveComment, replyToComment, CollaborationAuthority } from 'ooxml-core/docx/ui';
|
|
15
|
+
import { markSpecs, imageNodeSpec, fieldMarkerNodeSpec, noteReferenceNodeSpec, pageBreakNodeSpec, hardBreakNodeSpec, commentHistoryAttributes, tableCellStyle, tableStyle, createToggleFormat, expectDefined, controlFromData, paragraphBoxCss, WORD_CAPABILITY_ACTIONS, normalizeThemeMode, applyThemeColors, refreshWordYjsPresence, tableGrid, RESTRUCTURE_TABLE_META, normalizeRibbonActions, DirtyState, isFormsProtected, isWordYjsRemoteTransaction, REMOTE_TRANSACTION_META, repairCollaborativeDocumentIds, HEADER_FOOTER_INPUT, splitCell, closeRect, mergeCells, deleteColumns, insertColumn, deleteRow, insertRow, rowSpanOf, continuationsOf, wordYjsPluginKey, wordYjsRedo, wordYjsUndo, documentWordCount, restoreSectionParts, commentThreadsFromDoc, restoreNoteParts, CollaborationClient, createCollaborationIdGenerator, WordYjsCollaboration, insertContentControl, sectionPartsJson, NotePartsStep, notePartsJson, SectionPartsStep, fitZoomPercent, hasChangeAtCursor, hasAnyChange, commentIdsAtSelection, commentAnchors, fieldGuardPlugin, tableStructureGuardPlugin, contentControlPlugin, formFieldGuardPlugin, symbolFontPlugin, positionalTabInputPlugin, trackChangesPlugin, wordYjsPresencePlugin, placementClass, removeCommentThread, removeCommentAnchor, deleteComment, updateCommentThreads, addComment, toggleTrackChanges, goToNextChange, goToPreviousChange, rejectAllChanges, acceptAllChanges, rejectChangeAtCursor, acceptChangeAtCursor, goToComment, selectedChart, appendInlineNode, sameJson, sameRuns, PARAGRAPH_KEEP_KEYS, paragraphFromAttrs, parseBordersJson, isNavigableHref, setReviewRecordingPreferences, insertChartImage, nodeNumbering, controlAtSelection, paragraphFormattingRevision, inlineNodeRun, formattingRevision, insertWordHardBreak, paragraphAttrs, resolveCellVisuals, previewDocxDiagram, themeDrawing, chartNodeSpec, replaceSelectedChart, ribbonActionIdForLabel, removeWordLink, fieldResultRanges, wordLinkRangeAt, ligatureCss as ligatureCss$1, toggleCheckboxControl, formFieldBeside, formFieldOfNode, formFieldLocked, toggleFormCheckboxAt, runToInlineNodes as runToInlineNodes$1, insertedTextMarks, backstageFocus, applyRunFormattingPatch, clearDirectRunFormatting, applyWordLink, deleteFieldSelection, emptySimpleFieldResult, ligatureStyle, wordHighlightColors, swatchColor, cssBorderSide, countWords, chooseListItem, chooseDate, selectFormDropDownAt, updateControlProperties, WORD_CAPABILITY_MENU_ITEMS, WORD_CAPABILITY_SHORTCUTS, WORD_CAPABILITY_BACKSTAGE_PAGES, WORD_CAPABILITY_FILE_COMMANDS, resolveComment, replyToComment, CollaborationAuthority } from 'ooxml-core/docx/ui';
|
|
16
16
|
export { CollaborationAuthority, CollaborationClient, RIBBON_ACTION_IDS, RIBBON_ACTION_LABELS, WORD_CAPABILITY_IDS, createCollaborationIdGenerator, darkTheme, isRibbonActionId, lightTheme, normalizeRibbonActions, repairCollaborativeDocumentIds, themeToCssVars } from 'ooxml-core/docx/ui';
|
|
17
17
|
import { createDocument, saveDocx, sectionsFromLayout, sectionLayoutJson, sectionsOf, pageSizeOf, columnPreset, applyPageSetup, withSection, computeListLabels, numberNotesInOrder, tocEntries, editDocxChartEx, editDocxChart, resolveNumberingLevel, formatDocxDiagram, createDocxDiagram, insertedDiagramPartNames, changeDocxDiagramLayout, tableOfFiguresInstruction, findTableOfContents, applyDocxChartDataSheetEdits, docxChartDataSheet, newDocxChart, newChartImage, docxChartPaint, ensureListDefinition, equalColumnDraft, readColumnDraft, PAGE_SIZE_OPTIONS, PAGE_SIZES, readPageSetup, isRunHiddenForReview, resolveTableStyleFormatting, resolveParagraphFormatting, displayListLabel, setTitlePage, setLineNumbering, setVerticalAlign, setPageNumbering, ST_NumberFormat, unequalColumnPreset, setColumns, setOrientation, setPageSize, setMargins, lineSpacingLabel, formatNoteNumber, cellSourceBlocks, reviewDocumentFormatting, reviewFormattingWarnings, listRevisions, diagramColorTheme, plainText, resolveRunFormatting, removedByEdit, editDocxDiagram, tocHyperlinks, DEFAULT_TOC_INSTRUCTION, tocBookmarks, buildTableOfContents, tocCaptionLabel, twips as twips$1, signedTwips, formatListNumber, columnTextWidth, validColumnDraft, validatePageSetup, presetOf, LIGATURE_VALUES, isLigatures, reviewRunFormatting, resolveThemeColorReference, lineSpacingValue, canEditControlContent, controlDate, formDropDownIndex, shapeSvg, isStHighlightColor, transformCase, DEFAULT_TABLE_BORDERS, parseLineSpacingValue, twipsAttr, SHAPE_PALETTE, isHeadingListKind, twipsFromPixels, isFieldLocked, styleRefSource, parseStyleReference, bodyStyleRefResult, isDirectionalPreset, headingLevel, reviewParagraphFormatting, isValidLanguageTag, WORD, newShape, withFieldCodeFormatting, fieldResultRun, DEFAULT_DRAWN_SHAPE, fieldName, lineSpacingOptions, createListDefinition, linkStylesToList, headingListLevels, halfPointsFromPoints, changeColumnWidth, changeColumnGap, documentStats } from 'ooxml-core/docx';
|
|
18
18
|
import { loadDocument } from 'ooxml-core/docx/load';
|
|
@@ -30,6 +30,40 @@ import { applyChartExEditIntent, applyChartEditIntent, applyChartExEditAction, s
|
|
|
30
30
|
import { sendableSteps, getVersion } from 'prosemirror-collab';
|
|
31
31
|
import { isCapabilityEnabled, capabilityHiddenActions, mergeHiddenActions, saveToStorage, documentSaveMeta, fileCommandDetail, withoutHiddenEntries } from 'ooxml-core/embedding';
|
|
32
32
|
|
|
33
|
+
// src/docx/locales/split-cells.ts
|
|
34
|
+
var enSplitCells = {
|
|
35
|
+
"Merge cells": "Merge cells",
|
|
36
|
+
"Split cells": "Split cells",
|
|
37
|
+
"Number of rows": "Number of rows",
|
|
38
|
+
"Split the cell into this many columns and rows.": "Split the cell into this many columns and rows."
|
|
39
|
+
};
|
|
40
|
+
var fromValues = (values2) => Object.fromEntries(
|
|
41
|
+
Object.keys(enSplitCells).map((key2, index) => [key2, values2[index]])
|
|
42
|
+
);
|
|
43
|
+
var frSplitCells = fromValues([
|
|
44
|
+
"Fusionner les cellules",
|
|
45
|
+
"Fractionner les cellules",
|
|
46
|
+
"Nombre de lignes",
|
|
47
|
+
"Fractionnez la cellule en ce nombre de colonnes et de lignes."
|
|
48
|
+
]);
|
|
49
|
+
var deSplitCells = fromValues([
|
|
50
|
+
"Zellen verbinden",
|
|
51
|
+
"Zellen teilen",
|
|
52
|
+
"Anzahl der Zeilen",
|
|
53
|
+
"Teilen Sie die Zelle in diese Anzahl von Spalten und Zeilen."
|
|
54
|
+
]);
|
|
55
|
+
var esSplitCells = fromValues([
|
|
56
|
+
"Combinar celdas",
|
|
57
|
+
"Dividir celdas",
|
|
58
|
+
"N\xFAmero de filas",
|
|
59
|
+
"Divida la celda en este n\xFAmero de columnas y filas."
|
|
60
|
+
]);
|
|
61
|
+
var zhSplitCells = fromValues([
|
|
62
|
+
"\u5408\u5E76\u5355\u5143\u683C",
|
|
63
|
+
"\u62C6\u5206\u5355\u5143\u683C",
|
|
64
|
+
"\u884C\u6570",
|
|
65
|
+
"\u5C06\u5355\u5143\u683C\u62C6\u5206\u4E3A\u6B64\u6570\u91CF\u7684\u5217\u548C\u884C\u3002"
|
|
66
|
+
]);
|
|
33
67
|
var enOptions = {
|
|
34
68
|
...optionStrings.en,
|
|
35
69
|
"Change how document content is displayed on the screen.": "Change how document content is displayed on the screen.",
|
|
@@ -78,8 +112,8 @@ var enColumns = {
|
|
|
78
112
|
"Unequal column widths are preserved. Select Equal column width to replace them with equal columns.": "Unequal column widths are preserved. Select Equal column width to replace them with equal columns.",
|
|
79
113
|
"Enter whole columns and spacing that leaves at least 0.5 inch for each column.": "Enter whole columns and spacing that leaves at least 0.5 inch for each column."
|
|
80
114
|
};
|
|
81
|
-
var
|
|
82
|
-
var frColumns =
|
|
115
|
+
var fromValues2 = (values2) => Object.fromEntries(Object.keys(enColumns).map((key2, index) => [key2, values2[index]]));
|
|
116
|
+
var frColumns = fromValues2([
|
|
83
117
|
"Colonne",
|
|
84
118
|
"Autres colonnes\u2026",
|
|
85
119
|
"Largeur de colonne identique",
|
|
@@ -90,7 +124,7 @@ var frColumns = fromValues([
|
|
|
90
124
|
"Les largeurs in\xE9gales sont conserv\xE9es. S\xE9lectionnez Largeur de colonne identique pour les remplacer par des colonnes \xE9gales.",
|
|
91
125
|
"Saisissez un nombre entier de colonnes et un espacement laissant au moins 0,5 pouce par colonne."
|
|
92
126
|
]);
|
|
93
|
-
var deColumns =
|
|
127
|
+
var deColumns = fromValues2([
|
|
94
128
|
"Spalte",
|
|
95
129
|
"Weitere Spalten\u2026",
|
|
96
130
|
"Gleiche Spaltenbreite",
|
|
@@ -101,7 +135,7 @@ var deColumns = fromValues([
|
|
|
101
135
|
"Ungleiche Spaltenbreiten bleiben erhalten. W\xE4hlen Sie Gleiche Spaltenbreite, um sie durch gleiche Spalten zu ersetzen.",
|
|
102
136
|
"Geben Sie eine ganze Spaltenanzahl und einen Abstand ein, der jeder Spalte mindestens 0,5 Zoll l\xE4sst."
|
|
103
137
|
]);
|
|
104
|
-
var esColumns =
|
|
138
|
+
var esColumns = fromValues2([
|
|
105
139
|
"Columna",
|
|
106
140
|
"M\xE1s columnas\u2026",
|
|
107
141
|
"Columnas de igual ancho",
|
|
@@ -112,7 +146,7 @@ var esColumns = fromValues([
|
|
|
112
146
|
"Se conservan los anchos desiguales. Seleccione Columnas de igual ancho para sustituirlas por columnas iguales.",
|
|
113
147
|
"Escriba columnas enteras y un espaciado que deje al menos 0,5 pulgadas para cada columna."
|
|
114
148
|
]);
|
|
115
|
-
var zhColumns =
|
|
149
|
+
var zhColumns = fromValues2([
|
|
116
150
|
"\u680F",
|
|
117
151
|
"\u66F4\u591A\u5206\u680F\u2026",
|
|
118
152
|
"\u680F\u5BBD\u76F8\u7B49",
|
|
@@ -425,10 +459,10 @@ var enNavigation = {
|
|
|
425
459
|
"Collapse heading": "Collapse heading",
|
|
426
460
|
"Apply a heading style to see document headings here.": "Apply a heading style to see document headings here."
|
|
427
461
|
};
|
|
428
|
-
var
|
|
462
|
+
var fromValues3 = (values2) => Object.fromEntries(
|
|
429
463
|
Object.keys(enNavigation).map((key2, index) => [key2, values2[index]])
|
|
430
464
|
);
|
|
431
|
-
var frNavigation =
|
|
465
|
+
var frNavigation = fromValues3([
|
|
432
466
|
"Volet de navigation",
|
|
433
467
|
"Navigation",
|
|
434
468
|
"Titres",
|
|
@@ -437,7 +471,7 @@ var frNavigation = fromValues2([
|
|
|
437
471
|
"R\xE9duire le titre",
|
|
438
472
|
"Appliquez un style de titre pour afficher les titres du document ici."
|
|
439
473
|
]);
|
|
440
|
-
var deNavigation =
|
|
474
|
+
var deNavigation = fromValues3([
|
|
441
475
|
"Navigationsbereich",
|
|
442
476
|
"Navigation",
|
|
443
477
|
"\xDCberschriften",
|
|
@@ -446,7 +480,7 @@ var deNavigation = fromValues2([
|
|
|
446
480
|
"\xDCberschrift reduzieren",
|
|
447
481
|
"Wenden Sie eine \xDCberschriftenformatvorlage an, um hier Dokument\xFCberschriften anzuzeigen."
|
|
448
482
|
]);
|
|
449
|
-
var esNavigation =
|
|
483
|
+
var esNavigation = fromValues3([
|
|
450
484
|
"Panel de navegaci\xF3n",
|
|
451
485
|
"Navegaci\xF3n",
|
|
452
486
|
"T\xEDtulos",
|
|
@@ -455,7 +489,7 @@ var esNavigation = fromValues2([
|
|
|
455
489
|
"Contraer t\xEDtulo",
|
|
456
490
|
"Aplique un estilo de t\xEDtulo para ver aqu\xED los t\xEDtulos del documento."
|
|
457
491
|
]);
|
|
458
|
-
var zhNavigation =
|
|
492
|
+
var zhNavigation = fromValues3([
|
|
459
493
|
"\u5BFC\u822A\u7A97\u683C",
|
|
460
494
|
"\u5BFC\u822A",
|
|
461
495
|
"\u6807\u9898",
|
|
@@ -472,26 +506,26 @@ var enDropCap = {
|
|
|
472
506
|
"Lines to drop": "Lines to drop",
|
|
473
507
|
"Enter a font, 1 to 10 lines and a distance from 0 to 22 inches.": "Enter a font, 1 to 10 lines and a distance from 0 to 22 inches."
|
|
474
508
|
};
|
|
475
|
-
var
|
|
476
|
-
var frDropCap =
|
|
509
|
+
var fromValues4 = (values2) => Object.fromEntries(Object.keys(enDropCap).map((key2, index) => [key2, values2[index]]));
|
|
510
|
+
var frDropCap = fromValues4([
|
|
477
511
|
"Options de lettrine",
|
|
478
512
|
"Options de lettrine\u2026",
|
|
479
513
|
"Hauteur en lignes",
|
|
480
514
|
"Saisissez une police, 1 \xE0 10 lignes et une distance de 0 \xE0 22 pouces."
|
|
481
515
|
]);
|
|
482
|
-
var deDropCap =
|
|
516
|
+
var deDropCap = fromValues4([
|
|
483
517
|
"Initialoptionen",
|
|
484
518
|
"Initialoptionen\u2026",
|
|
485
519
|
"Initialh\xF6he in Zeilen",
|
|
486
520
|
"Geben Sie eine Schriftart, 1 bis 10 Zeilen und einen Abstand von 0 bis 22 Zoll ein."
|
|
487
521
|
]);
|
|
488
|
-
var esDropCap =
|
|
522
|
+
var esDropCap = fromValues4([
|
|
489
523
|
"Opciones de letra capital",
|
|
490
524
|
"Opciones de letra capital\u2026",
|
|
491
525
|
"L\xEDneas que ocupa",
|
|
492
526
|
"Escriba una fuente, de 1 a 10 l\xEDneas y una distancia de 0 a 22 pulgadas."
|
|
493
527
|
]);
|
|
494
|
-
var zhDropCap =
|
|
528
|
+
var zhDropCap = fromValues4([
|
|
495
529
|
"\u9996\u5B57\u4E0B\u6C89\u9009\u9879",
|
|
496
530
|
"\u9996\u5B57\u4E0B\u6C89\u9009\u9879\u2026",
|
|
497
531
|
"\u4E0B\u6C89\u884C\u6570",
|
|
@@ -511,10 +545,10 @@ var enLineNumbers = {
|
|
|
511
545
|
"Line Numbering Options\u2026": "Line Numbering Options\u2026",
|
|
512
546
|
"Enter whole numbers from 1 to 32767 and a distance from 0 to 22 inches.": "Enter whole numbers from 1 to 32767 and a distance from 0 to 22 inches."
|
|
513
547
|
};
|
|
514
|
-
var
|
|
548
|
+
var fromValues5 = (values2) => Object.fromEntries(
|
|
515
549
|
Object.keys(enLineNumbers).map((key2, index) => [key2, values2[index]])
|
|
516
550
|
);
|
|
517
|
-
var frLineNumbers =
|
|
551
|
+
var frLineNumbers = fromValues5([
|
|
518
552
|
"Ajouter la num\xE9rotation des lignes",
|
|
519
553
|
"Distance automatique du texte",
|
|
520
554
|
"Commencer \xE0",
|
|
@@ -526,7 +560,7 @@ var frLineNumbers = fromValues4([
|
|
|
526
560
|
"Options de num\xE9rotation des lignes\u2026",
|
|
527
561
|
"Saisissez des entiers de 1 \xE0 32767 et une distance de 0 \xE0 22 pouces."
|
|
528
562
|
]);
|
|
529
|
-
var deLineNumbers =
|
|
563
|
+
var deLineNumbers = fromValues5([
|
|
530
564
|
"Zeilennummern hinzuf\xFCgen",
|
|
531
565
|
"Automatischer Abstand zum Text",
|
|
532
566
|
"Beginnen mit",
|
|
@@ -538,7 +572,7 @@ var deLineNumbers = fromValues4([
|
|
|
538
572
|
"Zeilennummerierungsoptionen\u2026",
|
|
539
573
|
"Geben Sie ganze Zahlen von 1 bis 32767 und einen Abstand von 0 bis 22 Zoll ein."
|
|
540
574
|
]);
|
|
541
|
-
var esLineNumbers =
|
|
575
|
+
var esLineNumbers = fromValues5([
|
|
542
576
|
"Agregar n\xFAmeros de l\xEDnea",
|
|
543
577
|
"Distancia autom\xE1tica del texto",
|
|
544
578
|
"Iniciar en",
|
|
@@ -550,7 +584,7 @@ var esLineNumbers = fromValues4([
|
|
|
550
584
|
"Opciones de numeraci\xF3n de l\xEDneas\u2026",
|
|
551
585
|
"Introduzca enteros de 1 a 32767 y una distancia de 0 a 22 pulgadas."
|
|
552
586
|
]);
|
|
553
|
-
var zhLineNumbers =
|
|
587
|
+
var zhLineNumbers = fromValues5([
|
|
554
588
|
"\u6DFB\u52A0\u884C\u53F7",
|
|
555
589
|
"\u81EA\u52A8\u8BBE\u7F6E\u8DDD\u6B63\u6587\u7684\u8DDD\u79BB",
|
|
556
590
|
"\u8D77\u59CB\u7F16\u53F7",
|
|
@@ -1680,10 +1714,10 @@ var enTableProperties = {
|
|
|
1680
1714
|
"Justified (imported)": "Justified (imported)",
|
|
1681
1715
|
"Enter a measurement within the displayed range.": "Enter a measurement within the displayed range."
|
|
1682
1716
|
};
|
|
1683
|
-
var
|
|
1717
|
+
var fromValues6 = (values2) => Object.fromEntries(
|
|
1684
1718
|
Object.keys(enTableProperties).map((key2, index) => [key2, values2[index]])
|
|
1685
1719
|
);
|
|
1686
|
-
var frTableProperties =
|
|
1720
|
+
var frTableProperties = fromValues6([
|
|
1687
1721
|
"Propri\xE9t\xE9s du tableau",
|
|
1688
1722
|
"Propri\xE9t\xE9s",
|
|
1689
1723
|
"Ligne",
|
|
@@ -1708,7 +1742,7 @@ var frTableProperties = fromValues5([
|
|
|
1708
1742
|
"Justifi\xE9 (import\xE9)",
|
|
1709
1743
|
"Saisissez une mesure dans la plage affich\xE9e."
|
|
1710
1744
|
]);
|
|
1711
|
-
var deTableProperties =
|
|
1745
|
+
var deTableProperties = fromValues6([
|
|
1712
1746
|
"Tabelleneigenschaften",
|
|
1713
1747
|
"Eigenschaften",
|
|
1714
1748
|
"Zeile",
|
|
@@ -1733,7 +1767,7 @@ var deTableProperties = fromValues5([
|
|
|
1733
1767
|
"Blocksatz (importiert)",
|
|
1734
1768
|
"Geben Sie einen Wert im angezeigten Bereich ein."
|
|
1735
1769
|
]);
|
|
1736
|
-
var esTableProperties =
|
|
1770
|
+
var esTableProperties = fromValues6([
|
|
1737
1771
|
"Propiedades de tabla",
|
|
1738
1772
|
"Propiedades",
|
|
1739
1773
|
"Fila",
|
|
@@ -1758,7 +1792,7 @@ var esTableProperties = fromValues5([
|
|
|
1758
1792
|
"Justificado (importado)",
|
|
1759
1793
|
"Introduzca una medida dentro del intervalo mostrado."
|
|
1760
1794
|
]);
|
|
1761
|
-
var zhTableProperties =
|
|
1795
|
+
var zhTableProperties = fromValues6([
|
|
1762
1796
|
"\u8868\u683C\u5C5E\u6027",
|
|
1763
1797
|
"\u5C5E\u6027",
|
|
1764
1798
|
"\u884C",
|
|
@@ -2227,6 +2261,7 @@ var de = {
|
|
|
2227
2261
|
...deDropCap,
|
|
2228
2262
|
...deNavigation,
|
|
2229
2263
|
...deColumns,
|
|
2264
|
+
...deSplitCells,
|
|
2230
2265
|
...deMultilevelList,
|
|
2231
2266
|
...deFontAdvanced,
|
|
2232
2267
|
...deLigatures,
|
|
@@ -2930,6 +2965,7 @@ var en = {
|
|
|
2930
2965
|
...enDropCap,
|
|
2931
2966
|
...enNavigation,
|
|
2932
2967
|
...enColumns,
|
|
2968
|
+
...enSplitCells,
|
|
2933
2969
|
...enMultilevelList,
|
|
2934
2970
|
...enFontAdvanced,
|
|
2935
2971
|
...enLigatures,
|
|
@@ -3633,6 +3669,7 @@ var es = {
|
|
|
3633
3669
|
...esDropCap,
|
|
3634
3670
|
...esNavigation,
|
|
3635
3671
|
...esColumns,
|
|
3672
|
+
...esSplitCells,
|
|
3636
3673
|
...esMultilevelList,
|
|
3637
3674
|
...esFontAdvanced,
|
|
3638
3675
|
...esLigatures,
|
|
@@ -4336,6 +4373,7 @@ var fr = {
|
|
|
4336
4373
|
...frDropCap,
|
|
4337
4374
|
...frNavigation,
|
|
4338
4375
|
...frColumns,
|
|
4376
|
+
...frSplitCells,
|
|
4339
4377
|
...frMultilevelList,
|
|
4340
4378
|
...frFontAdvanced,
|
|
4341
4379
|
...frLigatures,
|
|
@@ -5039,6 +5077,7 @@ var zhCN = {
|
|
|
5039
5077
|
...zhDropCap,
|
|
5040
5078
|
...zhNavigation,
|
|
5041
5079
|
...zhColumns,
|
|
5080
|
+
...zhSplitCells,
|
|
5042
5081
|
...zhMultilevelList,
|
|
5043
5082
|
...zhFontAdvanced,
|
|
5044
5083
|
...zhLigatures,
|
|
@@ -5569,6 +5608,8 @@ var paths = {
|
|
|
5569
5608
|
columnLeft: "M10 4h10v16H10z M15 4v16 M3 12h4 M5 10v4",
|
|
5570
5609
|
columnRight: "M4 4h10v16H4z M9 4v16 M17 12h4 M19 10v4",
|
|
5571
5610
|
deleteColumn: "M6 4h9v16H6z M10.5 4v16 M19 8v8",
|
|
5611
|
+
mergeCells: "M4 5h16v14H4z M4 12h4 M16 12h4 M10 9l-3 3 3 3 M14 9l3 3-3 3",
|
|
5612
|
+
splitCell: "M4 5h16v14H4z M12 5v14 M8 9l-3 3 3 3 M16 9l3 3-3 3",
|
|
5572
5613
|
deleteTable: "M4 5h16v14H4z M4 10h16 M10 5v14 M14 13l5 5 M19 13l-5 5",
|
|
5573
5614
|
margins: "M5 3h14v18H5z M8 6h8v12H8z",
|
|
5574
5615
|
orientation: "M6 3h9l3 3v15H6z M12 9v6 M9 12h6",
|
|
@@ -6445,6 +6486,18 @@ function buildHomePanel(panels) {
|
|
|
6445
6486
|
{ type: "tableEdit", key: "deleteColumn" },
|
|
6446
6487
|
{ large: true }
|
|
6447
6488
|
),
|
|
6489
|
+
tool(
|
|
6490
|
+
"Merge cells",
|
|
6491
|
+
"mergeCells",
|
|
6492
|
+
{ type: "tableEdit", key: "mergeCells" },
|
|
6493
|
+
{ large: true }
|
|
6494
|
+
),
|
|
6495
|
+
tool(
|
|
6496
|
+
"Split cells",
|
|
6497
|
+
"splitCell",
|
|
6498
|
+
{ type: "formatDialog", kind: "splitCells" },
|
|
6499
|
+
{ large: true }
|
|
6500
|
+
),
|
|
6448
6501
|
tool(
|
|
6449
6502
|
"Delete table",
|
|
6450
6503
|
"deleteTable",
|
|
@@ -7125,6 +7178,10 @@ var schema = new Schema({
|
|
|
7125
7178
|
attrs: {
|
|
7126
7179
|
id: { default: "" },
|
|
7127
7180
|
structureEditable: { default: true },
|
|
7181
|
+
/** Merged or nested table whose rows, columns and cells the structure commands can edit. */
|
|
7182
|
+
restructurable: { default: false },
|
|
7183
|
+
/** The table's `w:tblGrid` widths as JSON, kept so column edits reach the model. */
|
|
7184
|
+
grid: { default: null },
|
|
7128
7185
|
widthTwips: { default: null },
|
|
7129
7186
|
alignment: { default: null },
|
|
7130
7187
|
indentTwips: { default: null },
|
|
@@ -7138,7 +7195,8 @@ var schema = new Schema({
|
|
|
7138
7195
|
toDOM: (node) => ["table", { style: tableStyle(node.attrs) }, ["tbody", 0]]
|
|
7139
7196
|
},
|
|
7140
7197
|
tableRow: {
|
|
7141
|
-
|
|
7198
|
+
// A row whose cells all continue vertical merges from above holds no cell of its own.
|
|
7199
|
+
content: "tableCell*",
|
|
7142
7200
|
/** Row formatting travels with the row during structural edits and undo. */
|
|
7143
7201
|
attrs: { heightPx: { default: null }, properties: { default: null } },
|
|
7144
7202
|
parseDOM: [{ tag: "tr" }],
|
|
@@ -7155,6 +7213,8 @@ var schema = new Schema({
|
|
|
7155
7213
|
sourceCellKey: { default: "" },
|
|
7156
7214
|
colspan: { default: 1 },
|
|
7157
7215
|
rowspan: { default: 1 },
|
|
7216
|
+
/** First-paragraph ids (JSON) of the continuation cells a vertical merge has below this cell. */
|
|
7217
|
+
continueKeys: { default: null },
|
|
7158
7218
|
widthTwips: { default: null },
|
|
7159
7219
|
verticalAlign: { default: null },
|
|
7160
7220
|
shadingFill: { default: null },
|
|
@@ -8949,14 +9009,307 @@ function setRibbonLocale(root, value) {
|
|
|
8949
9009
|
refitRibbon(root);
|
|
8950
9010
|
}
|
|
8951
9011
|
var runToInlineNodes = (run, noteNumber) => runToInlineNodes$1(run, schema, noteNumber);
|
|
9012
|
+
var keysOf = (cell) => {
|
|
9013
|
+
try {
|
|
9014
|
+
const parsed2 = JSON.parse(String(cell.attrs.continueKeys ?? "[]"));
|
|
9015
|
+
return Array.isArray(parsed2) ? parsed2.map(String) : [];
|
|
9016
|
+
} catch {
|
|
9017
|
+
return [];
|
|
9018
|
+
}
|
|
9019
|
+
};
|
|
9020
|
+
var gridOf = (table) => {
|
|
9021
|
+
try {
|
|
9022
|
+
const parsed2 = table.attrs.grid ? JSON.parse(String(table.attrs.grid)) : void 0;
|
|
9023
|
+
return Array.isArray(parsed2) ? parsed2.map(Number) : void 0;
|
|
9024
|
+
} catch {
|
|
9025
|
+
return void 0;
|
|
9026
|
+
}
|
|
9027
|
+
};
|
|
9028
|
+
function slotsOf(table) {
|
|
9029
|
+
const pending = /* @__PURE__ */ new Map();
|
|
9030
|
+
const rows = [];
|
|
9031
|
+
table.forEach((row3, _offset, r) => {
|
|
9032
|
+
const carried = [...pending.get(r) ?? []].sort((a, b) => a.col - b.col);
|
|
9033
|
+
const slots = [];
|
|
9034
|
+
const cells = [];
|
|
9035
|
+
row3.forEach((cell) => cells.push(cell));
|
|
9036
|
+
let col = 0;
|
|
9037
|
+
let next = 0;
|
|
9038
|
+
while (carried.length || next < cells.length) {
|
|
9039
|
+
const continued = carried[0];
|
|
9040
|
+
if (continued && continued.col === col) {
|
|
9041
|
+
slots.push(continued);
|
|
9042
|
+
col += continued.span;
|
|
9043
|
+
carried.shift();
|
|
9044
|
+
continue;
|
|
9045
|
+
}
|
|
9046
|
+
const cell = cells[next++];
|
|
9047
|
+
if (!cell) break;
|
|
9048
|
+
const span = Number(cell.attrs.colspan) || 1;
|
|
9049
|
+
const key2 = String(cell.attrs.sourceCellKey || "");
|
|
9050
|
+
slots.push({ row: r, col, span, cell, offset: 0, key: key2 });
|
|
9051
|
+
const rowspan = Number(cell.attrs.rowspan) || 1;
|
|
9052
|
+
const names = keysOf(cell);
|
|
9053
|
+
for (let k = 1; k < rowspan; k++)
|
|
9054
|
+
pending.set(r + k, [
|
|
9055
|
+
...pending.get(r + k) ?? [],
|
|
9056
|
+
{ row: r + k, col, span, cell, offset: k, key: names[k - 1] ?? `${key2}~${k}` }
|
|
9057
|
+
]);
|
|
9058
|
+
col += span;
|
|
9059
|
+
}
|
|
9060
|
+
rows.push(slots);
|
|
9061
|
+
});
|
|
9062
|
+
return rows;
|
|
9063
|
+
}
|
|
9064
|
+
var json = (value) => {
|
|
9065
|
+
try {
|
|
9066
|
+
return typeof value === "string" ? JSON.parse(value) : void 0;
|
|
9067
|
+
} catch {
|
|
9068
|
+
return void 0;
|
|
9069
|
+
}
|
|
9070
|
+
};
|
|
9071
|
+
function skeletonOf(table) {
|
|
9072
|
+
const rows = slotsOf(table).map(
|
|
9073
|
+
(slots) => slots.map((slot2) => {
|
|
9074
|
+
const { cell } = slot2;
|
|
9075
|
+
const base = slot2.offset === 0 ? { paragraphs: [] } : { paragraphs: [{ type: "paragraph", id: slot2.key, runs: [{ text: "" }] }] };
|
|
9076
|
+
if (slot2.span > 1) base.gridSpan = slot2.span;
|
|
9077
|
+
const width = cell.attrs.widthTwips;
|
|
9078
|
+
if (width != null) base.widthTwips = width;
|
|
9079
|
+
if (slot2.offset > 0) {
|
|
9080
|
+
base.verticalMerge = "continue";
|
|
9081
|
+
return base;
|
|
9082
|
+
}
|
|
9083
|
+
if (Number(cell.attrs.rowspan) > 1) base.verticalMerge = "restart";
|
|
9084
|
+
cell.forEach((child) => {
|
|
9085
|
+
if (child.type.name === "paragraph")
|
|
9086
|
+
base.paragraphs.push({
|
|
9087
|
+
type: "paragraph",
|
|
9088
|
+
id: String(child.attrs.id),
|
|
9089
|
+
runs: [{ text: child.textContent }]
|
|
9090
|
+
});
|
|
9091
|
+
else if (child.type.name === "table")
|
|
9092
|
+
(base.sourceBlocks ??= []).push({ type: "table", id: String(child.attrs.id), rows: [] });
|
|
9093
|
+
else (base.nestedTables ??= []).push({ rows: [] });
|
|
9094
|
+
});
|
|
9095
|
+
if (!base.paragraphs.length)
|
|
9096
|
+
base.paragraphs.push({ type: "paragraph", id: slot2.key, runs: [{ text: "" }] });
|
|
9097
|
+
if (cell.attrs.verticalAlign) base.verticalAlign = cell.attrs.verticalAlign;
|
|
9098
|
+
if (cell.attrs.directShadingFill) base.shadingFill = String(cell.attrs.directShadingFill);
|
|
9099
|
+
const borders = json(cell.attrs.directBorders);
|
|
9100
|
+
if (borders) base.borders = borders;
|
|
9101
|
+
const margins = json(cell.attrs.margins);
|
|
9102
|
+
if (margins) base.margins = margins;
|
|
9103
|
+
return base;
|
|
9104
|
+
})
|
|
9105
|
+
);
|
|
9106
|
+
const model = { type: "table", id: String(table.attrs.id), rows };
|
|
9107
|
+
const grid = gridOf(table);
|
|
9108
|
+
if (grid) model.grid = grid;
|
|
9109
|
+
const properties = [];
|
|
9110
|
+
table.forEach((row3) => properties.push(structuredClone(row3.attrs.properties ?? {})));
|
|
9111
|
+
if (properties.some((entry) => Object.keys(entry).length)) model.rowProperties = properties;
|
|
9112
|
+
return model;
|
|
9113
|
+
}
|
|
9114
|
+
var FORMAT_KEYS = [
|
|
9115
|
+
"style",
|
|
9116
|
+
"align",
|
|
9117
|
+
"justification",
|
|
9118
|
+
"direction",
|
|
9119
|
+
"spacingBeforeTwips",
|
|
9120
|
+
"spacingAfterTwips",
|
|
9121
|
+
"lineSpacingTwips",
|
|
9122
|
+
"lineSpacingRule",
|
|
9123
|
+
"indentLeftTwips",
|
|
9124
|
+
"indentRightTwips",
|
|
9125
|
+
"indentStartTwips",
|
|
9126
|
+
"indentEndTwips",
|
|
9127
|
+
"firstLineTwips",
|
|
9128
|
+
"hangingTwips"
|
|
9129
|
+
];
|
|
9130
|
+
function paragraphNode(model, known) {
|
|
9131
|
+
const existing = known.get(model.id);
|
|
9132
|
+
if (existing) return existing;
|
|
9133
|
+
const attrs = { id: model.id };
|
|
9134
|
+
const source = model;
|
|
9135
|
+
for (const key2 of FORMAT_KEYS) if (source[key2] !== void 0) attrs[key2] = source[key2];
|
|
9136
|
+
return schema.nodes.paragraph.create(attrs);
|
|
9137
|
+
}
|
|
9138
|
+
function nodeFromResult(old, result) {
|
|
9139
|
+
const grid = tableGrid(result);
|
|
9140
|
+
if (!grid) return void 0;
|
|
9141
|
+
const cellOf = /* @__PURE__ */ new Map();
|
|
9142
|
+
const known = /* @__PURE__ */ new Map();
|
|
9143
|
+
for (const row3 of slotsOf(old))
|
|
9144
|
+
for (const slot2 of row3) {
|
|
9145
|
+
if (slot2.offset) continue;
|
|
9146
|
+
slot2.cell.forEach((child) => {
|
|
9147
|
+
if (child.type.name !== "paragraph") return;
|
|
9148
|
+
known.set(String(child.attrs.id), child);
|
|
9149
|
+
cellOf.set(String(child.attrs.id), slot2.cell);
|
|
9150
|
+
});
|
|
9151
|
+
}
|
|
9152
|
+
const rows = grid.rows.map((entries, r) => {
|
|
9153
|
+
const cells = [];
|
|
9154
|
+
for (const entry of entries) {
|
|
9155
|
+
const model = entry.cell;
|
|
9156
|
+
if (model.verticalMerge === "continue") continue;
|
|
9157
|
+
const rowspan = rowSpanOf(grid, entry);
|
|
9158
|
+
const keys2 = continuationsOf(grid, entry).map((c) => c.cell.paragraphs[0]?.id ?? "");
|
|
9159
|
+
const ids = model.paragraphs.map((p) => p.id);
|
|
9160
|
+
const source = ids.map((id) => cellOf.get(id)).find(Boolean);
|
|
9161
|
+
const attrs = {
|
|
9162
|
+
...source?.attrs ?? {},
|
|
9163
|
+
colspan: entry.span,
|
|
9164
|
+
rowspan,
|
|
9165
|
+
widthTwips: model.widthTwips ?? null,
|
|
9166
|
+
continueKeys: keys2.length ? JSON.stringify(keys2) : null
|
|
9167
|
+
};
|
|
9168
|
+
if (!source) {
|
|
9169
|
+
Object.assign(attrs, {
|
|
9170
|
+
sourceCellKey: ids[0] ?? "",
|
|
9171
|
+
verticalAlign: model.verticalAlign ?? null,
|
|
9172
|
+
shadingFill: model.shadingFill ?? null,
|
|
9173
|
+
directShadingFill: model.shadingFill ?? null,
|
|
9174
|
+
borders: model.borders ? JSON.stringify(model.borders) : null,
|
|
9175
|
+
directBorders: model.borders ? JSON.stringify(model.borders) : null,
|
|
9176
|
+
margins: model.margins ? JSON.stringify(model.margins) : null,
|
|
9177
|
+
contentControl: null
|
|
9178
|
+
});
|
|
9179
|
+
}
|
|
9180
|
+
const content = [];
|
|
9181
|
+
const wanted = new Set(ids);
|
|
9182
|
+
source?.forEach((child) => {
|
|
9183
|
+
if (child.type.name !== "paragraph" || wanted.has(String(child.attrs.id)))
|
|
9184
|
+
content.push(child);
|
|
9185
|
+
});
|
|
9186
|
+
const present = new Set(content.map((child) => String(child.attrs.id)));
|
|
9187
|
+
for (const paragraph2 of model.paragraphs)
|
|
9188
|
+
if (!present.has(paragraph2.id)) content.push(paragraphNode(paragraph2, known));
|
|
9189
|
+
cells.push(schema.nodes.tableCell.create(attrs, content));
|
|
9190
|
+
}
|
|
9191
|
+
const properties = result.rowProperties?.[r];
|
|
9192
|
+
const height = properties?.heightTwips;
|
|
9193
|
+
return schema.nodes.tableRow.create(
|
|
9194
|
+
{
|
|
9195
|
+
heightPx: height ? height / 15 : null,
|
|
9196
|
+
properties: properties && Object.keys(properties).length ? properties : null
|
|
9197
|
+
},
|
|
9198
|
+
cells
|
|
9199
|
+
);
|
|
9200
|
+
});
|
|
9201
|
+
return schema.nodes.table.create(
|
|
9202
|
+
{
|
|
9203
|
+
...old.attrs,
|
|
9204
|
+
// A table that was edited this way is saved through the merge-aware writer from now on.
|
|
9205
|
+
structureEditable: false,
|
|
9206
|
+
restructurable: true,
|
|
9207
|
+
grid: result.grid ? JSON.stringify(result.grid) : null
|
|
9208
|
+
},
|
|
9209
|
+
rows
|
|
9210
|
+
);
|
|
9211
|
+
}
|
|
9212
|
+
|
|
9213
|
+
// src/docx/table-restructure-convert.ts
|
|
9214
|
+
var keyOf = (cell) => cell.paragraphs[0]?.id ?? "";
|
|
9215
|
+
function structureChanged(node, prior) {
|
|
9216
|
+
const fromNode = slotsOf(node).map(
|
|
9217
|
+
(row3) => row3.map((slot2) => [
|
|
9218
|
+
slot2.key,
|
|
9219
|
+
slot2.span,
|
|
9220
|
+
slot2.offset ? "continue" : Number(slot2.cell.attrs.rowspan) > 1 ? "restart" : "",
|
|
9221
|
+
slot2.cell.attrs.widthTwips ?? null
|
|
9222
|
+
])
|
|
9223
|
+
);
|
|
9224
|
+
const layout = tableGrid(prior);
|
|
9225
|
+
const fromModel = prior.rows.map(
|
|
9226
|
+
(row3, r) => row3.map((cell, index) => {
|
|
9227
|
+
const entry = layout?.rows[r]?.[index];
|
|
9228
|
+
const merge = cell.verticalMerge === "restart" && layout && entry && rowSpanOf(layout, entry) === 1 ? "" : cell.verticalMerge ?? "";
|
|
9229
|
+
return [keyOf(cell), cell.gridSpan ?? 1, merge, cell.widthTwips ?? null];
|
|
9230
|
+
})
|
|
9231
|
+
);
|
|
9232
|
+
return JSON.stringify(fromNode) !== JSON.stringify(fromModel) || JSON.stringify(gridOf(node) ?? null) !== JSON.stringify(prior.grid ?? null);
|
|
9233
|
+
}
|
|
9234
|
+
function convertRestructuredTable(node, prior, convertParagraph, convertNested, heldControl2) {
|
|
9235
|
+
const updated = structuredClone(prior);
|
|
9236
|
+
updated.structureEditable = false;
|
|
9237
|
+
updated.restructurable = true;
|
|
9238
|
+
const sources = /* @__PURE__ */ new Map();
|
|
9239
|
+
for (const row3 of prior.rows) for (const cell of row3) sources.set(keyOf(cell), cell);
|
|
9240
|
+
const before = tableGrid(prior);
|
|
9241
|
+
const merged = /* @__PURE__ */ new Map();
|
|
9242
|
+
for (const entry of before?.rows.flat() ?? [])
|
|
9243
|
+
if (entry.cell.verticalMerge === "restart")
|
|
9244
|
+
merged.set(keyOf(entry.cell), rowSpanOf(before, entry));
|
|
9245
|
+
updated.rows = slotsOf(node).map(
|
|
9246
|
+
(slots) => slots.map((slot2) => {
|
|
9247
|
+
const base = sources.get(slot2.key);
|
|
9248
|
+
const cell = base ? structuredClone(base) : { paragraphs: [] };
|
|
9249
|
+
if (slot2.span > 1) cell.gridSpan = slot2.span;
|
|
9250
|
+
else delete cell.gridSpan;
|
|
9251
|
+
const width = slot2.cell.attrs.widthTwips;
|
|
9252
|
+
if (width != null) cell.widthTwips = width;
|
|
9253
|
+
else delete cell.widthTwips;
|
|
9254
|
+
if (slot2.offset > 0) {
|
|
9255
|
+
cell.verticalMerge = "continue";
|
|
9256
|
+
if (!cell.paragraphs.length)
|
|
9257
|
+
cell.paragraphs = [{ type: "paragraph", id: slot2.key, runs: [{ text: "" }] }];
|
|
9258
|
+
return cell;
|
|
9259
|
+
}
|
|
9260
|
+
if (Number(slot2.cell.attrs.rowspan) > 1) cell.verticalMerge = "restart";
|
|
9261
|
+
else if (!(base?.verticalMerge === "restart" && (merged.get(slot2.key) ?? 1) === 1))
|
|
9262
|
+
delete cell.verticalMerge;
|
|
9263
|
+
const paragraphs = [];
|
|
9264
|
+
const nested = [];
|
|
9265
|
+
slot2.cell.forEach((child) => {
|
|
9266
|
+
if (child.type.name === "paragraph") paragraphs.push(convertParagraph(child));
|
|
9267
|
+
else if (child.type.name === "table") nested.push(child);
|
|
9268
|
+
});
|
|
9269
|
+
if (paragraphs.length) cell.paragraphs = paragraphs;
|
|
9270
|
+
const attrs = slot2.cell.attrs;
|
|
9271
|
+
if (!base || attrs.shadingEdited) {
|
|
9272
|
+
delete cell.shadingThemeFill;
|
|
9273
|
+
if (attrs.directShadingFill) cell.shadingFill = String(attrs.directShadingFill);
|
|
9274
|
+
else delete cell.shadingFill;
|
|
9275
|
+
}
|
|
9276
|
+
const borders = typeof attrs.directBorders === "string" ? attrs.directBorders : null;
|
|
9277
|
+
if (borders) cell.borders = JSON.parse(borders);
|
|
9278
|
+
else if (!base) delete cell.borders;
|
|
9279
|
+
if (typeof attrs.margins === "string")
|
|
9280
|
+
cell.margins = JSON.parse(attrs.margins);
|
|
9281
|
+
if (typeof attrs.verticalAlign === "string")
|
|
9282
|
+
cell.verticalAlign = attrs.verticalAlign;
|
|
9283
|
+
delete cell.contentControl;
|
|
9284
|
+
Object.assign(cell, heldControl2(slot2.cell, base?.contentControl));
|
|
9285
|
+
let index = 0;
|
|
9286
|
+
if (cell.sourceBlocks)
|
|
9287
|
+
cell.sourceBlocks = cell.sourceBlocks.map((block) => {
|
|
9288
|
+
const target = block.type === "table" ? nested[index++] : void 0;
|
|
9289
|
+
return target && block.type === "table" ? convertNested(target, block) : block;
|
|
9290
|
+
});
|
|
9291
|
+
return cell;
|
|
9292
|
+
})
|
|
9293
|
+
);
|
|
9294
|
+
const grid = gridOf(node);
|
|
9295
|
+
if (grid) updated.grid = grid;
|
|
9296
|
+
const properties = [];
|
|
9297
|
+
node.forEach((row3) => properties.push(structuredClone(row3.attrs.properties ?? {})));
|
|
9298
|
+
if (properties.some((entry) => Object.keys(entry).length)) updated.rowProperties = properties;
|
|
9299
|
+
else delete updated.rowProperties;
|
|
9300
|
+
return updated;
|
|
9301
|
+
}
|
|
9302
|
+
|
|
9303
|
+
// src/docx/table-model-adapter.ts
|
|
8952
9304
|
function cellKey(cell) {
|
|
8953
9305
|
return cell.paragraphs[0]?.id ?? "";
|
|
8954
9306
|
}
|
|
8955
|
-
function tableNode(block,
|
|
9307
|
+
function tableNode(block, paragraphNode3, tableStyles, nested = false) {
|
|
8956
9308
|
const columnCount = Math.max(
|
|
8957
9309
|
1,
|
|
8958
9310
|
...block.rows.map((row3) => row3.reduce((sum, cell) => sum + (cell.gridSpan ?? 1), 0))
|
|
8959
9311
|
);
|
|
9312
|
+
const layout = tableGrid(block);
|
|
8960
9313
|
const rows = block.rows.map((row3, rowIndex) => {
|
|
8961
9314
|
const cells = [];
|
|
8962
9315
|
let gridColumn = 0;
|
|
@@ -8965,7 +9318,10 @@ function tableNode(block, paragraphNode2, tableStyles, nested = false) {
|
|
|
8965
9318
|
gridColumn += cell.gridSpan ?? 1;
|
|
8966
9319
|
if (cell.verticalMerge === "continue") return;
|
|
8967
9320
|
let rowspan = 1;
|
|
8968
|
-
|
|
9321
|
+
const entry = layout?.rows[rowIndex]?.[columnIndex];
|
|
9322
|
+
const continues = layout && entry ? continuationsOf(layout, entry) : [];
|
|
9323
|
+
if (layout && entry) rowspan = rowSpanOf(layout, entry);
|
|
9324
|
+
else if (cell.verticalMerge === "restart") {
|
|
8969
9325
|
let next = rowIndex + 1;
|
|
8970
9326
|
while (block.rows[next]?.[columnIndex]?.verticalMerge === "continue") {
|
|
8971
9327
|
rowspan++;
|
|
@@ -8986,9 +9342,9 @@ function tableNode(block, paragraphNode2, tableStyles, nested = false) {
|
|
|
8986
9342
|
tableStyles
|
|
8987
9343
|
);
|
|
8988
9344
|
const children = cell.sourceBlocks ? cellSourceBlocks(cell).map(
|
|
8989
|
-
(child) => child.type === "paragraph" ?
|
|
9345
|
+
(child) => child.type === "paragraph" ? paragraphNode3(child) : tableNode(child, paragraphNode3, tableStyles, true)
|
|
8990
9346
|
) : [
|
|
8991
|
-
...cell.paragraphs.map(
|
|
9347
|
+
...cell.paragraphs.map(paragraphNode3),
|
|
8992
9348
|
...(cell.nestedTables ?? []).map(
|
|
8993
9349
|
(preview) => schema.nodes.nestedTablePreview.create({ rowsJson: JSON.stringify(preview.rows) })
|
|
8994
9350
|
)
|
|
@@ -9000,6 +9356,7 @@ function tableNode(block, paragraphNode2, tableStyles, nested = false) {
|
|
|
9000
9356
|
sourceCellKey: cellKey(cell),
|
|
9001
9357
|
colspan: cell.gridSpan ?? 1,
|
|
9002
9358
|
rowspan,
|
|
9359
|
+
continueKeys: continues.length ? JSON.stringify(continues.map((c) => cellKey(c.cell))) : null,
|
|
9003
9360
|
widthTwips: cell.widthTwips ?? null,
|
|
9004
9361
|
verticalAlign: cell.verticalAlign ?? null,
|
|
9005
9362
|
shadingFill: visuals.shadingFill ?? null,
|
|
@@ -9029,6 +9386,9 @@ function tableNode(block, paragraphNode2, tableStyles, nested = false) {
|
|
|
9029
9386
|
id: block.id,
|
|
9030
9387
|
// Nested tables edit their text on the page; their grid and merges stay as authored.
|
|
9031
9388
|
structureEditable: !nested && block.structureEditable !== false,
|
|
9389
|
+
// Merge and split work on any table whose cells tile its grid.
|
|
9390
|
+
restructurable: block.restructurable === true || block.structureEditable !== false && Boolean(layout),
|
|
9391
|
+
grid: block.grid ? JSON.stringify(block.grid) : null,
|
|
9032
9392
|
widthTwips: block.widthTwips ?? null,
|
|
9033
9393
|
alignment: block.alignment ?? null,
|
|
9034
9394
|
indentTwips: block.indentTwips ?? null,
|
|
@@ -9123,12 +9483,26 @@ function convertMergedTable(node, prior, convertParagraph) {
|
|
|
9123
9483
|
if (target.sourceBlocks)
|
|
9124
9484
|
target.sourceBlocks = target.sourceBlocks.map((block) => {
|
|
9125
9485
|
const node2 = block.type === "table" ? nested[index++] : void 0;
|
|
9126
|
-
return node2 && block.type === "table" ?
|
|
9486
|
+
return node2 && block.type === "table" ? convertStructuredTable(node2, block, convertParagraph) : block;
|
|
9127
9487
|
});
|
|
9128
9488
|
})
|
|
9129
9489
|
);
|
|
9130
9490
|
return updated;
|
|
9131
9491
|
}
|
|
9492
|
+
function convertStructuredTable(node, prior, convertParagraph) {
|
|
9493
|
+
if (!node.attrs.restructurable || !structureChanged(node, prior))
|
|
9494
|
+
return convertMergedTable(node, prior, convertParagraph);
|
|
9495
|
+
const updated = convertRestructuredTable(
|
|
9496
|
+
node,
|
|
9497
|
+
prior,
|
|
9498
|
+
convertParagraph,
|
|
9499
|
+
(inner, innerPrior) => convertStructuredTable(inner, innerPrior, convertParagraph),
|
|
9500
|
+
heldControl
|
|
9501
|
+
);
|
|
9502
|
+
delete updated.contentControl;
|
|
9503
|
+
Object.assign(updated, tableControl(node, prior));
|
|
9504
|
+
return updated;
|
|
9505
|
+
}
|
|
9132
9506
|
function selectedBlockIndex(view) {
|
|
9133
9507
|
return view.state.selection.$from.index(0);
|
|
9134
9508
|
}
|
|
@@ -9171,8 +9545,8 @@ function sectionBreaksPlugin() {
|
|
|
9171
9545
|
return new Plugin({
|
|
9172
9546
|
props: {
|
|
9173
9547
|
decorations(state) {
|
|
9174
|
-
const
|
|
9175
|
-
const sections = typeof
|
|
9548
|
+
const json2 = state.doc.attrs.sections;
|
|
9549
|
+
const sections = typeof json2 === "string" ? JSON.parse(json2) : [];
|
|
9176
9550
|
if (sections.length < 2) return null;
|
|
9177
9551
|
const labels3 = /* @__PURE__ */ new Map();
|
|
9178
9552
|
sections.slice(0, -1).forEach((section3, index) => {
|
|
@@ -9195,7 +9569,7 @@ function sectionBreaksPlugin() {
|
|
|
9195
9569
|
}
|
|
9196
9570
|
});
|
|
9197
9571
|
}
|
|
9198
|
-
function
|
|
9572
|
+
function paragraphNode2(paragraph2, labels3, noteNumber) {
|
|
9199
9573
|
const label2 = labels3.get(paragraph2.id);
|
|
9200
9574
|
const children = paragraph2.runs.flatMap((run) => runToInlineNodes(run, noteNumber));
|
|
9201
9575
|
return schema.node(
|
|
@@ -9221,10 +9595,10 @@ function modelToDoc(model) {
|
|
|
9221
9595
|
return { number: number2, label: formatNoteNumber(number2, format) };
|
|
9222
9596
|
};
|
|
9223
9597
|
const blocks = model.blocks.map((block) => {
|
|
9224
|
-
if (block.type === "paragraph") return
|
|
9598
|
+
if (block.type === "paragraph") return paragraphNode2(block, labels3, noteNumber);
|
|
9225
9599
|
return tableNode(
|
|
9226
9600
|
block,
|
|
9227
|
-
(paragraph2) =>
|
|
9601
|
+
(paragraph2) => paragraphNode2(paragraph2, labels3, noteNumber),
|
|
9228
9602
|
model.tableStyles
|
|
9229
9603
|
);
|
|
9230
9604
|
});
|
|
@@ -9344,8 +9718,8 @@ function docToModel(doc, prior, previousDoc) {
|
|
|
9344
9718
|
const id = String(node.attrs.id || `t-edit-${++nextId}`);
|
|
9345
9719
|
const prior2 = priorTables.get(id);
|
|
9346
9720
|
const asParagraph = (n) => convertParagraph(n);
|
|
9347
|
-
if (prior2 && prior2.structureEditable === false)
|
|
9348
|
-
blocks.push(
|
|
9721
|
+
if (prior2 && (prior2.structureEditable === false || node.attrs.structureEditable === false && node.attrs.restructurable))
|
|
9722
|
+
blocks.push(convertStructuredTable(node, prior2, asParagraph));
|
|
9349
9723
|
else
|
|
9350
9724
|
blocks.push({
|
|
9351
9725
|
// Table-level properties (grid, width, borders, style, look) have no editor node;
|
|
@@ -10179,6 +10553,134 @@ function toggleVerticalAlign(view, value) {
|
|
|
10179
10553
|
function applyVerticalAlign(view, value) {
|
|
10180
10554
|
applyRunFormattingPatch({ verticalAlign: value })(view.state, view.dispatch, view);
|
|
10181
10555
|
}
|
|
10556
|
+
function restructureContext(view) {
|
|
10557
|
+
const { $from, from: from2, to } = view.state.selection;
|
|
10558
|
+
let depth = $from.depth;
|
|
10559
|
+
while (depth > 0 && $from.node(depth).type !== schema.nodes.table) depth--;
|
|
10560
|
+
if (depth <= 0 || $from.depth < depth + 2) return void 0;
|
|
10561
|
+
const table = $from.node(depth);
|
|
10562
|
+
if (!table.attrs.restructurable) return void 0;
|
|
10563
|
+
const tablePos = $from.before(depth);
|
|
10564
|
+
const skeleton = skeletonOf(table);
|
|
10565
|
+
if (!tableGrid(skeleton)) return void 0;
|
|
10566
|
+
const slots = slotsOf(table);
|
|
10567
|
+
const positions = /* @__PURE__ */ new Map();
|
|
10568
|
+
table.forEach(
|
|
10569
|
+
(row3, rowOffset) => row3.forEach(
|
|
10570
|
+
(cell, cellOffset) => positions.set(cell, tablePos + 1 + rowOffset + 1 + cellOffset)
|
|
10571
|
+
)
|
|
10572
|
+
);
|
|
10573
|
+
const selected = [];
|
|
10574
|
+
slots.forEach(
|
|
10575
|
+
(row3) => row3.forEach((slot2, index) => {
|
|
10576
|
+
const pos = positions.get(slot2.cell);
|
|
10577
|
+
if (slot2.offset || pos === void 0) return;
|
|
10578
|
+
if (Math.max(from2, pos + 1) <= Math.min(to, pos + slot2.cell.nodeSize - 1))
|
|
10579
|
+
selected.push({ slot: slot2, index });
|
|
10580
|
+
})
|
|
10581
|
+
);
|
|
10582
|
+
if (!selected.length) return void 0;
|
|
10583
|
+
const rect = { firstRow: Infinity, lastRow: -1, firstCol: Infinity, lastCol: -1 };
|
|
10584
|
+
for (const { slot: slot2 } of selected) {
|
|
10585
|
+
rect.firstRow = Math.min(rect.firstRow, slot2.row);
|
|
10586
|
+
rect.lastRow = Math.max(rect.lastRow, slot2.row + (Number(slot2.cell.attrs.rowspan) || 1) - 1);
|
|
10587
|
+
rect.firstCol = Math.min(rect.firstCol, slot2.col);
|
|
10588
|
+
rect.lastCol = Math.max(rect.lastCol, slot2.col + slot2.span - 1);
|
|
10589
|
+
}
|
|
10590
|
+
return {
|
|
10591
|
+
table,
|
|
10592
|
+
tablePos,
|
|
10593
|
+
nested: $from.node(depth - 1).type === schema.nodes.tableCell,
|
|
10594
|
+
skeleton,
|
|
10595
|
+
selected,
|
|
10596
|
+
rect
|
|
10597
|
+
};
|
|
10598
|
+
}
|
|
10599
|
+
function usesRestructure(ctx, action) {
|
|
10600
|
+
if (!ctx) return false;
|
|
10601
|
+
return action === "mergeCells" || action === "splitCell" || ctx.nested || ctx.table.attrs.structureEditable === false;
|
|
10602
|
+
}
|
|
10603
|
+
function compute(ctx, action, newId, split2) {
|
|
10604
|
+
const { skeleton, rect } = ctx;
|
|
10605
|
+
switch (action) {
|
|
10606
|
+
case "rowBefore":
|
|
10607
|
+
return insertRow(skeleton, rect.firstRow, "above", newId);
|
|
10608
|
+
case "rowAfter":
|
|
10609
|
+
return insertRow(skeleton, rect.lastRow, "below", newId);
|
|
10610
|
+
case "deleteRow": {
|
|
10611
|
+
let table = skeleton;
|
|
10612
|
+
for (let r = rect.lastRow; r >= rect.firstRow; r--) {
|
|
10613
|
+
const next = deleteRow(table, r);
|
|
10614
|
+
if (!next) return "table";
|
|
10615
|
+
table = next;
|
|
10616
|
+
}
|
|
10617
|
+
return table;
|
|
10618
|
+
}
|
|
10619
|
+
// Word measures a single selected cell from its first column, a merged one included.
|
|
10620
|
+
case "columnBefore":
|
|
10621
|
+
return insertColumn(skeleton, rect.firstCol, "left", newId);
|
|
10622
|
+
case "columnAfter":
|
|
10623
|
+
return insertColumn(
|
|
10624
|
+
skeleton,
|
|
10625
|
+
ctx.selected.length === 1 ? rect.firstCol : rect.lastCol,
|
|
10626
|
+
"right",
|
|
10627
|
+
newId
|
|
10628
|
+
);
|
|
10629
|
+
case "deleteColumn":
|
|
10630
|
+
return rect.firstCol === 0 && rect.lastCol >= (skeleton.grid?.length ?? Infinity) - 1 ? "table" : deleteColumns(skeleton, rect.firstCol, rect.lastCol);
|
|
10631
|
+
case "mergeCells": {
|
|
10632
|
+
const closed = closeRect(skeleton, rect);
|
|
10633
|
+
return closed && mergeCells(skeleton, closed, newId);
|
|
10634
|
+
}
|
|
10635
|
+
case "splitCell": {
|
|
10636
|
+
const target = ctx.selected[0];
|
|
10637
|
+
if (!target || ctx.selected.length !== 1) return void 0;
|
|
10638
|
+
return splitCell(
|
|
10639
|
+
skeleton,
|
|
10640
|
+
target.slot.row,
|
|
10641
|
+
target.index,
|
|
10642
|
+
split2?.rows ?? 1,
|
|
10643
|
+
split2?.columns ?? 2,
|
|
10644
|
+
newId
|
|
10645
|
+
);
|
|
10646
|
+
}
|
|
10647
|
+
}
|
|
10648
|
+
}
|
|
10649
|
+
function canRestructure(ctx, action) {
|
|
10650
|
+
let serial2 = 0;
|
|
10651
|
+
const outcome = compute(ctx, action, () => `probe-${++serial2}`);
|
|
10652
|
+
return outcome !== void 0;
|
|
10653
|
+
}
|
|
10654
|
+
function splitTarget(view) {
|
|
10655
|
+
const ctx = restructureContext(view);
|
|
10656
|
+
const only = ctx?.selected.length === 1 ? ctx.selected[0] : void 0;
|
|
10657
|
+
if (!ctx || !only) return void 0;
|
|
10658
|
+
const grid = tableGrid(ctx.skeleton);
|
|
10659
|
+
const entry = grid?.rows[only.slot.row]?.[only.index];
|
|
10660
|
+
return grid && entry ? { rows: rowSpanOf(grid, entry), span: entry.span } : void 0;
|
|
10661
|
+
}
|
|
10662
|
+
function executeRestructure(view, action, newId, split2) {
|
|
10663
|
+
const ctx = restructureContext(view);
|
|
10664
|
+
if (!ctx || !view.editable) return false;
|
|
10665
|
+
const outcome = compute(ctx, action, newId, split2);
|
|
10666
|
+
if (!outcome) return false;
|
|
10667
|
+
const { tablePos, table } = ctx;
|
|
10668
|
+
let replacement;
|
|
10669
|
+
if (outcome === "table") replacement = schema.nodes.paragraph.create({ id: newId() });
|
|
10670
|
+
else replacement = nodeFromResult(table, outcome);
|
|
10671
|
+
if (!replacement) return false;
|
|
10672
|
+
const transaction = closeHistory(
|
|
10673
|
+
view.state.tr.replaceWith(tablePos, tablePos + table.nodeSize, replacement)
|
|
10674
|
+
);
|
|
10675
|
+
transaction.setMeta(RESTRUCTURE_TABLE_META, true);
|
|
10676
|
+
transaction.setSelection(
|
|
10677
|
+
Selection.near(transaction.doc.resolve(tablePos + (outcome === "table" ? 1 : 2)))
|
|
10678
|
+
);
|
|
10679
|
+
view.dispatch(transaction.scrollIntoView());
|
|
10680
|
+
return true;
|
|
10681
|
+
}
|
|
10682
|
+
|
|
10683
|
+
// src/docx/table-commands.ts
|
|
10182
10684
|
function context(view) {
|
|
10183
10685
|
const { $from } = view.state.selection;
|
|
10184
10686
|
let tableDepth = -1;
|
|
@@ -10238,15 +10740,38 @@ function replaceWithParagraph(view, ctx) {
|
|
|
10238
10740
|
view.dispatch(transaction.scrollIntoView());
|
|
10239
10741
|
}
|
|
10240
10742
|
function canExecuteTableCommand(view, action) {
|
|
10743
|
+
if (action === "deleteTable") return canDeleteTable(view);
|
|
10744
|
+
const merged = restructureContext(view);
|
|
10745
|
+
if (usesRestructure(merged, action))
|
|
10746
|
+
return Boolean(view.editable && merged && canRestructure(merged, action));
|
|
10241
10747
|
const ctx = context(view);
|
|
10242
10748
|
const nested = ctx && view.state.selection.$from.node(ctx.tableDepth - 1).type.name === "tableCell";
|
|
10243
|
-
return Boolean(
|
|
10244
|
-
|
|
10245
|
-
|
|
10749
|
+
return Boolean(view.editable && ctx && !nested && ctx.table.attrs.structureEditable !== false);
|
|
10750
|
+
}
|
|
10751
|
+
function canDeleteTable(view) {
|
|
10752
|
+
const ctx = context(view) ?? tableAround(view);
|
|
10753
|
+
const nested = ctx && view.state.selection.$from.node(ctx.tableDepth - 1).type === schema.nodes.tableCell;
|
|
10754
|
+
return Boolean(view.editable && ctx && !nested);
|
|
10246
10755
|
}
|
|
10247
|
-
function
|
|
10756
|
+
function tableAround(view) {
|
|
10757
|
+
const { $from } = view.state.selection;
|
|
10758
|
+
for (let depth = $from.depth; depth > 0; depth--)
|
|
10759
|
+
if ($from.node(depth).type === schema.nodes.table && depth > 0 && $from.depth >= depth + 2)
|
|
10760
|
+
return {
|
|
10761
|
+
table: $from.node(depth),
|
|
10762
|
+
tablePos: $from.before(depth),
|
|
10763
|
+
tableDepth: depth,
|
|
10764
|
+
rowIndex: $from.index(depth),
|
|
10765
|
+
columnIndex: $from.index(depth + 1)
|
|
10766
|
+
};
|
|
10767
|
+
return null;
|
|
10768
|
+
}
|
|
10769
|
+
function executeTableCommand(view, action, split2) {
|
|
10248
10770
|
if (!canExecuteTableCommand(view, action)) return false;
|
|
10249
|
-
const
|
|
10771
|
+
const merged = restructureContext(view);
|
|
10772
|
+
if (action !== "deleteTable" && usesRestructure(merged, action))
|
|
10773
|
+
return executeRestructure(view, action, paragraphIdFactory(view), split2);
|
|
10774
|
+
const ctx = context(view) ?? tableAround(view);
|
|
10250
10775
|
if (!ctx) return false;
|
|
10251
10776
|
if (action === "deleteTable") {
|
|
10252
10777
|
replaceWithParagraph(view, ctx);
|
|
@@ -16921,6 +17446,75 @@ function createDropCapDialog(getView) {
|
|
|
16921
17446
|
}
|
|
16922
17447
|
};
|
|
16923
17448
|
}
|
|
17449
|
+
|
|
17450
|
+
// src/docx/split-cells-dialog.ts
|
|
17451
|
+
function createSplitCellsDialog(viewOf) {
|
|
17452
|
+
const element = createDialogShell("Split cells", "dve-format-dialog");
|
|
17453
|
+
const columns = numberInput(1, 63, 1);
|
|
17454
|
+
const rows = numberInput(1, 63, 1);
|
|
17455
|
+
const note = document.createElement("p");
|
|
17456
|
+
note.textContent = "Split the cell into this many columns and rows.";
|
|
17457
|
+
const cancel = dialogButton("Cancel");
|
|
17458
|
+
const ok = dialogButton("OK", true);
|
|
17459
|
+
const content = [
|
|
17460
|
+
fieldset(
|
|
17461
|
+
"Split cells",
|
|
17462
|
+
row2(labelled("Number of columns", columns), labelled("Number of rows", rows))
|
|
17463
|
+
),
|
|
17464
|
+
note,
|
|
17465
|
+
dialogActions(cancel, ok)
|
|
17466
|
+
];
|
|
17467
|
+
let locale = "en";
|
|
17468
|
+
const valid = () => [columns, rows].every(
|
|
17469
|
+
(input) => Number.isInteger(Number(input.value)) && Number(input.value) >= 1
|
|
17470
|
+
);
|
|
17471
|
+
const validate = () => ok.disabled = !valid();
|
|
17472
|
+
const hide = () => {
|
|
17473
|
+
setDialogOpen(element, false);
|
|
17474
|
+
element.replaceChildren();
|
|
17475
|
+
viewOf()?.focus();
|
|
17476
|
+
};
|
|
17477
|
+
const submit = () => {
|
|
17478
|
+
const view = viewOf();
|
|
17479
|
+
if (!view || !valid()) return;
|
|
17480
|
+
const split2 = { rows: Number(rows.value), columns: Number(columns.value) };
|
|
17481
|
+
hide();
|
|
17482
|
+
executeTableCommand(view, "splitCell", split2);
|
|
17483
|
+
};
|
|
17484
|
+
columns.addEventListener("input", validate);
|
|
17485
|
+
rows.addEventListener("input", validate);
|
|
17486
|
+
cancel.addEventListener("click", hide);
|
|
17487
|
+
ok.addEventListener("click", submit);
|
|
17488
|
+
onDialogDismiss(element, hide);
|
|
17489
|
+
element.addEventListener("keydown", (event) => {
|
|
17490
|
+
if (event.key === "Enter" && event.target instanceof HTMLInputElement) {
|
|
17491
|
+
event.preventDefault();
|
|
17492
|
+
submit();
|
|
17493
|
+
}
|
|
17494
|
+
});
|
|
17495
|
+
return {
|
|
17496
|
+
element,
|
|
17497
|
+
close: hide,
|
|
17498
|
+
setLocale(next) {
|
|
17499
|
+
locale = next;
|
|
17500
|
+
},
|
|
17501
|
+
get isOpen() {
|
|
17502
|
+
return isDialogOpen(element);
|
|
17503
|
+
},
|
|
17504
|
+
open() {
|
|
17505
|
+
const view = viewOf();
|
|
17506
|
+
const target = view && splitTarget(view);
|
|
17507
|
+
if (!view?.editable || !target) return;
|
|
17508
|
+
element.replaceChildren(...content);
|
|
17509
|
+
localizeDialog(element, locale);
|
|
17510
|
+
columns.value = "2";
|
|
17511
|
+
rows.value = "1";
|
|
17512
|
+
validate();
|
|
17513
|
+
setDialogOpen(element, true);
|
|
17514
|
+
columns.focus();
|
|
17515
|
+
}
|
|
17516
|
+
};
|
|
17517
|
+
}
|
|
16924
17518
|
function createColumnsDialog(host) {
|
|
16925
17519
|
const element = createDialogShell("Columns", "dve-format-dialog");
|
|
16926
17520
|
const count = numberInput(1, 45, 1);
|
|
@@ -17470,6 +18064,7 @@ var FormatDialogs = class {
|
|
|
17470
18064
|
}),
|
|
17471
18065
|
borders: createBordersDialog(() => host.view()),
|
|
17472
18066
|
tableProperties: createTablePropertiesDialog(() => host.view()),
|
|
18067
|
+
splitCells: createSplitCellsDialog(() => host.view()),
|
|
17473
18068
|
watermark: createWatermarkDialog({
|
|
17474
18069
|
...host.watermark ?? { current: () => void 0, canEdit: () => false, apply: () => {
|
|
17475
18070
|
} },
|
|
@@ -17860,6 +18455,8 @@ function refreshEditorControls(toolbar, view, model, readOnly, collaboration, lo
|
|
|
17860
18455
|
button3.disabled = readOnly || Boolean(collaboration) || !canExecuteTableCommand(view, action.key);
|
|
17861
18456
|
if (action.type === "formatDialog" && action.kind === "tableProperties")
|
|
17862
18457
|
button3.disabled = readOnly || !tablePropertiesContext(state);
|
|
18458
|
+
if (action.type === "formatDialog" && action.kind === "splitCells")
|
|
18459
|
+
button3.disabled = readOnly || Boolean(collaboration) || !canExecuteTableCommand(view, "splitCell");
|
|
17863
18460
|
}
|
|
17864
18461
|
syncFontControls(toolbar, state);
|
|
17865
18462
|
syncParagraphControls(toolbar, state);
|
|
@@ -20589,6 +21186,9 @@ var DOCX_EDITOR_ATTRIBUTES = [
|
|
|
20589
21186
|
];
|
|
20590
21187
|
var DEFAULT_FILE_NAME = "Document1.docx";
|
|
20591
21188
|
var DEFAULT_REVIEW_AUTHOR = "Author";
|
|
21189
|
+
function modifiedStamp(reviewAuthor) {
|
|
21190
|
+
return reviewAuthor && reviewAuthor !== DEFAULT_REVIEW_AUTHOR ? { author: reviewAuthor } : {};
|
|
21191
|
+
}
|
|
20592
21192
|
function isDocxEditorAttribute(name) {
|
|
20593
21193
|
return DOCX_EDITOR_ATTRIBUTES.includes(name);
|
|
20594
21194
|
}
|
|
@@ -21605,6 +22205,10 @@ function renderTable(box2, columnWidthPx, renderParagraph) {
|
|
|
21605
22205
|
content.className = "dve-print-cell-content";
|
|
21606
22206
|
content.style.zIndex = "2";
|
|
21607
22207
|
const offset = cellVerticalOffset(geometry, row3.heightPx);
|
|
22208
|
+
if (geometry.mergeRows && geometry.mergeRows > 1) {
|
|
22209
|
+
cell.style.overflow = "visible";
|
|
22210
|
+
rowEl.style.zIndex = "1";
|
|
22211
|
+
}
|
|
21608
22212
|
Object.assign(content.style, {
|
|
21609
22213
|
left: `${geometry.paddingLeftPx - (geometry.borderInsetsReserved ? measuredBorderWidth(cssBorder(borders?.left), borders?.left?.widthPx ?? 0) : 0)}px`,
|
|
21610
22214
|
right: `${geometry.paddingRightPx - (geometry.borderInsetsReserved && cellIndex === row3.cells.length - 1 ? measuredBorderWidth(cssBorder(borders?.right), borders?.right?.widthPx ?? 0) : 0)}px`,
|
|
@@ -26400,6 +27004,8 @@ var TABLE_ITEMS = [
|
|
|
26400
27004
|
["columnBefore", "Insert column left"],
|
|
26401
27005
|
["columnAfter", "Insert column right"],
|
|
26402
27006
|
["deleteColumn", "Delete column"],
|
|
27007
|
+
["mergeCells", "Merge cells"],
|
|
27008
|
+
["splitCell", "Split cells"],
|
|
26403
27009
|
["deleteTable", "Delete table"]
|
|
26404
27010
|
];
|
|
26405
27011
|
function computeMenuItems(state) {
|
|
@@ -26451,7 +27057,7 @@ function computeMenuItems(state) {
|
|
|
26451
27057
|
TABLE_ITEMS.map(([key2, label2]) => ({
|
|
26452
27058
|
id: `table-${key2}`,
|
|
26453
27059
|
label: label2,
|
|
26454
|
-
command: { kind: "ribbon", action: { type: "tableEdit", key: key2 } },
|
|
27060
|
+
command: key2 === "splitCell" ? { kind: "ribbon", action: { type: "formatDialog", kind: "splitCells" } } : { kind: "ribbon", action: { type: "tableEdit", key: key2 } },
|
|
26455
27061
|
disabled: state.readOnly || !state.canTable(key2)
|
|
26456
27062
|
}))
|
|
26457
27063
|
);
|
|
@@ -27595,7 +28201,7 @@ var DocxEditorApi = class extends HTMLElementBase {
|
|
|
27595
28201
|
]);
|
|
27596
28202
|
const media = pending.size ? pending : void 0;
|
|
27597
28203
|
if (core.loaded)
|
|
27598
|
-
return
|
|
28204
|
+
return core.loaded.save(core.model, media, { modified: modifiedStamp(core.reviewAuthor) });
|
|
27599
28205
|
return saveDocx(core.model, media);
|
|
27600
28206
|
}
|
|
27601
28207
|
/** The saved document as a Blob. Does not change `dirty`; call `markClean()` after persisting it. */
|