@extend-ai/react-docx 0.11.2 → 0.11.3
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/dist/index.cjs +51 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -44732,6 +44732,9 @@ function DocxEditorViewer({
|
|
|
44732
44732
|
);
|
|
44733
44733
|
const runTableContextMenuAction = React3.useCallback(
|
|
44734
44734
|
(actionId, providedContext) => {
|
|
44735
|
+
if (isReadOnly) {
|
|
44736
|
+
return;
|
|
44737
|
+
}
|
|
44735
44738
|
const context = providedContext ?? tableContextMenuState;
|
|
44736
44739
|
if (!context) {
|
|
44737
44740
|
return;
|
|
@@ -44777,7 +44780,7 @@ function DocxEditorViewer({
|
|
|
44777
44780
|
}
|
|
44778
44781
|
closeTableContextMenu();
|
|
44779
44782
|
},
|
|
44780
|
-
[closeTableContextMenu, editor, tableContextMenuState]
|
|
44783
|
+
[closeTableContextMenu, editor, isReadOnly, tableContextMenuState]
|
|
44781
44784
|
);
|
|
44782
44785
|
const tableContextMenuActions = React3.useMemo(
|
|
44783
44786
|
() => [...DEFAULT_TABLE_CONTEXT_MENU_ACTIONS],
|
|
@@ -47094,7 +47097,7 @@ function DocxEditorViewer({
|
|
|
47094
47097
|
);
|
|
47095
47098
|
const onViewerContextMenu = React3.useCallback(
|
|
47096
47099
|
(event) => {
|
|
47097
|
-
if (
|
|
47100
|
+
if (event.defaultPrevented) {
|
|
47098
47101
|
return;
|
|
47099
47102
|
}
|
|
47100
47103
|
const target = event.target;
|
|
@@ -47124,8 +47127,10 @@ function DocxEditorViewer({
|
|
|
47124
47127
|
if (!boundary) {
|
|
47125
47128
|
return;
|
|
47126
47129
|
}
|
|
47127
|
-
|
|
47128
|
-
|
|
47130
|
+
if (!isReadOnly) {
|
|
47131
|
+
clearTableCellSelection();
|
|
47132
|
+
setSelectionFromDocxBoundaries(boundary, boundary);
|
|
47133
|
+
}
|
|
47129
47134
|
resolvedRange = {
|
|
47130
47135
|
start: {
|
|
47131
47136
|
location: cloneTextRangeLocation(boundary.location),
|
|
@@ -47136,7 +47141,7 @@ function DocxEditorViewer({
|
|
|
47136
47141
|
offset: boundary.offset
|
|
47137
47142
|
}
|
|
47138
47143
|
};
|
|
47139
|
-
} else if (resolvedRange) {
|
|
47144
|
+
} else if (resolvedRange && !isReadOnly) {
|
|
47140
47145
|
clearTableCellSelection();
|
|
47141
47146
|
editor.setActiveTextRange(resolvedRange);
|
|
47142
47147
|
}
|
|
@@ -47145,9 +47150,11 @@ function DocxEditorViewer({
|
|
|
47145
47150
|
) : void 0;
|
|
47146
47151
|
event.preventDefault();
|
|
47147
47152
|
event.stopPropagation();
|
|
47153
|
+
const tableContext = isReadOnly ? parseTableCellLocationFromElement(target) : void 0;
|
|
47148
47154
|
openContextMenu(
|
|
47149
47155
|
{
|
|
47150
|
-
kind: "text",
|
|
47156
|
+
kind: tableContext ? "table" : "text",
|
|
47157
|
+
tableContext,
|
|
47151
47158
|
activeTextRange: resolvedRange ? normalizeTextRange(resolvedRange) : void 0,
|
|
47152
47159
|
location
|
|
47153
47160
|
},
|
|
@@ -47572,7 +47579,7 @@ function DocxEditorViewer({
|
|
|
47572
47579
|
);
|
|
47573
47580
|
const resolveContextMenuActions = React3.useCallback(
|
|
47574
47581
|
(context) => {
|
|
47575
|
-
if (context.kind === "table") {
|
|
47582
|
+
if (context.kind === "table" && !isReadOnly) {
|
|
47576
47583
|
return tableContextMenuActions.map((action) => ({
|
|
47577
47584
|
id: action.id,
|
|
47578
47585
|
label: action.label,
|
|
@@ -47592,6 +47599,9 @@ function DocxEditorViewer({
|
|
|
47592
47599
|
disabled: (action.id === "cut" || action.id === "copy") && !hasExpandedRange
|
|
47593
47600
|
})
|
|
47594
47601
|
);
|
|
47602
|
+
if (isReadOnly) {
|
|
47603
|
+
return clipboardActions.filter((action) => action.id === "copy");
|
|
47604
|
+
}
|
|
47595
47605
|
if (context.kind !== "image") {
|
|
47596
47606
|
return clipboardActions;
|
|
47597
47607
|
}
|
|
@@ -47673,10 +47683,13 @@ function DocxEditorViewer({
|
|
|
47673
47683
|
...layerActions
|
|
47674
47684
|
];
|
|
47675
47685
|
},
|
|
47676
|
-
[tableContextMenuActions]
|
|
47686
|
+
[isReadOnly, tableContextMenuActions]
|
|
47677
47687
|
);
|
|
47678
47688
|
const runContextMenuAction = React3.useCallback(
|
|
47679
47689
|
(actionId, providedContext) => {
|
|
47690
|
+
if (isReadOnly && actionId !== "copy") {
|
|
47691
|
+
return;
|
|
47692
|
+
}
|
|
47680
47693
|
const isTableAction = (value) => value === "insert-row-above" || value === "insert-row-below" || value === "insert-column-left" || value === "insert-column-right" || value === "delete-row" || value === "delete-column" || value === "delete-table";
|
|
47681
47694
|
if (isTableAction(actionId)) {
|
|
47682
47695
|
const providedTableContext = providedContext?.kind === "table" ? providedContext.tableContext : void 0;
|
|
@@ -48037,7 +48050,7 @@ function DocxEditorViewer({
|
|
|
48037
48050
|
if (!hasExpandedRange) {
|
|
48038
48051
|
break;
|
|
48039
48052
|
}
|
|
48040
|
-
if (currentRange) {
|
|
48053
|
+
if (currentRange && !isReadOnly) {
|
|
48041
48054
|
restoreDomSelectionFromRange(currentRange);
|
|
48042
48055
|
}
|
|
48043
48056
|
const selectedText = resolveSelectedTextForRange(currentRange);
|
|
@@ -48197,6 +48210,7 @@ function DocxEditorViewer({
|
|
|
48197
48210
|
editor,
|
|
48198
48211
|
focusWrappedParagraphRange,
|
|
48199
48212
|
focusWrappedParagraphTextarea,
|
|
48213
|
+
isReadOnly,
|
|
48200
48214
|
replaceExpandedSelectionWithText,
|
|
48201
48215
|
resolveActiveRangeFromDomSelection,
|
|
48202
48216
|
runTableContextMenuAction,
|
|
@@ -53037,14 +53051,13 @@ function DocxEditorViewer({
|
|
|
53037
53051
|
}
|
|
53038
53052
|
},
|
|
53039
53053
|
onContextMenu: (event) => {
|
|
53040
|
-
if (isReadOnly) {
|
|
53041
|
-
return;
|
|
53042
|
-
}
|
|
53043
53054
|
event.preventDefault();
|
|
53044
53055
|
event.stopPropagation();
|
|
53045
|
-
|
|
53046
|
-
|
|
53047
|
-
|
|
53056
|
+
if (!isReadOnly) {
|
|
53057
|
+
clearTableCellSelection();
|
|
53058
|
+
setSelectedSectionImageKey(void 0);
|
|
53059
|
+
setSelectedImage(manualImageLocation);
|
|
53060
|
+
}
|
|
53048
53061
|
openContextMenu(
|
|
53049
53062
|
{
|
|
53050
53063
|
kind: "image",
|
|
@@ -53310,14 +53323,13 @@ function DocxEditorViewer({
|
|
|
53310
53323
|
}
|
|
53311
53324
|
},
|
|
53312
53325
|
onContextMenu: (event) => {
|
|
53313
|
-
if (isReadOnly) {
|
|
53314
|
-
return;
|
|
53315
|
-
}
|
|
53316
53326
|
event.preventDefault();
|
|
53317
53327
|
event.stopPropagation();
|
|
53318
|
-
|
|
53319
|
-
|
|
53320
|
-
|
|
53328
|
+
if (!isReadOnly) {
|
|
53329
|
+
clearTableCellSelection();
|
|
53330
|
+
setSelectedSectionImageKey(void 0);
|
|
53331
|
+
setSelectedImage(manualImageLocation);
|
|
53332
|
+
}
|
|
53321
53333
|
openContextMenu(
|
|
53322
53334
|
{
|
|
53323
53335
|
kind: "image",
|
|
@@ -53533,14 +53545,13 @@ function DocxEditorViewer({
|
|
|
53533
53545
|
}
|
|
53534
53546
|
},
|
|
53535
53547
|
onContextMenu: (event) => {
|
|
53536
|
-
if (isReadOnly) {
|
|
53537
|
-
return;
|
|
53538
|
-
}
|
|
53539
53548
|
event.preventDefault();
|
|
53540
53549
|
event.stopPropagation();
|
|
53541
|
-
|
|
53542
|
-
|
|
53543
|
-
|
|
53550
|
+
if (!isReadOnly) {
|
|
53551
|
+
clearTableCellSelection();
|
|
53552
|
+
setSelectedSectionImageKey(void 0);
|
|
53553
|
+
setSelectedImage(manualImageLocation);
|
|
53554
|
+
}
|
|
53544
53555
|
openContextMenu(
|
|
53545
53556
|
{
|
|
53546
53557
|
kind: "image",
|
|
@@ -53987,14 +53998,16 @@ function DocxEditorViewer({
|
|
|
53987
53998
|
}
|
|
53988
53999
|
},
|
|
53989
54000
|
onContextMenu: (event) => {
|
|
53990
|
-
if (
|
|
54001
|
+
if (behavesAsDecorativeBehindTextBackground) {
|
|
53991
54002
|
return;
|
|
53992
54003
|
}
|
|
53993
54004
|
event.preventDefault();
|
|
53994
54005
|
event.stopPropagation();
|
|
53995
|
-
|
|
53996
|
-
|
|
53997
|
-
|
|
54006
|
+
if (!isReadOnly) {
|
|
54007
|
+
clearTableCellSelection();
|
|
54008
|
+
setSelectedSectionImageKey(void 0);
|
|
54009
|
+
setSelectedImage(imageLocation);
|
|
54010
|
+
}
|
|
53998
54011
|
openContextMenu(
|
|
53999
54012
|
{
|
|
54000
54013
|
kind: "image",
|
|
@@ -54310,9 +54323,11 @@ function DocxEditorViewer({
|
|
|
54310
54323
|
onContextMenu: (event) => {
|
|
54311
54324
|
event.preventDefault();
|
|
54312
54325
|
event.stopPropagation();
|
|
54313
|
-
|
|
54314
|
-
|
|
54315
|
-
|
|
54326
|
+
if (!isReadOnly) {
|
|
54327
|
+
clearTableCellSelection();
|
|
54328
|
+
setSelectedSectionImageKey(void 0);
|
|
54329
|
+
setSelectedImage(imageLocation);
|
|
54330
|
+
}
|
|
54316
54331
|
openContextMenu(
|
|
54317
54332
|
{
|
|
54318
54333
|
kind: "image",
|
|
@@ -61560,13 +61575,13 @@ ${currentText.slice(end)}`;
|
|
|
61560
61575
|
}
|
|
61561
61576
|
}
|
|
61562
61577
|
) : null,
|
|
61563
|
-
|
|
61578
|
+
contextMenuState || tableContextMenuState ? (() => {
|
|
61564
61579
|
const hasCustomContextMenuState = Boolean(contextMenuState);
|
|
61565
61580
|
const hasTableContextMenuState = Boolean(tableContextMenuState);
|
|
61566
61581
|
if (!hasCustomContextMenuState && !hasTableContextMenuState) {
|
|
61567
61582
|
return null;
|
|
61568
61583
|
}
|
|
61569
|
-
if (hasCustomContextMenuState || renderContextMenu) {
|
|
61584
|
+
if (hasCustomContextMenuState || renderContextMenu || isReadOnly) {
|
|
61570
61585
|
const tableContext = tableContextMenuState ? {
|
|
61571
61586
|
tableIndex: tableContextMenuState.tableIndex,
|
|
61572
61587
|
rowIndex: tableContextMenuState.rowIndex,
|