@progress/kendo-react-editor 7.2.4-develop.3 → 7.3.0-develop.1
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/Editor.js +8 -0
- package/Editor.mjs +327 -0
- package/config/defaultStyles.js +229 -0
- package/config/defaultStyles.mjs +235 -0
- package/config/shortcuts.js +8 -0
- package/config/shortcuts.mjs +34 -0
- package/config/toolsSettings.js +8 -0
- package/config/toolsSettings.mjs +549 -0
- package/dialogs/FindReplace.js +8 -0
- package/dialogs/FindReplace.mjs +214 -0
- package/dialogs/index.js +8 -0
- package/dialogs/index.mjs +30 -0
- package/dialogs/insertImage.js +8 -0
- package/dialogs/insertImage.mjs +117 -0
- package/dialogs/insertLink.js +8 -0
- package/dialogs/insertLink.mjs +96 -0
- package/dialogs/viewHtml.js +8 -0
- package/dialogs/viewHtml.mjs +70 -0
- package/dist/cdn/js/kendo-react-editor.js +8 -226
- package/index.d.mts +2943 -5
- package/index.d.ts +2941 -178
- package/index.js +8 -226
- package/index.mjs +165 -4118
- package/messages/index.js +8 -0
- package/messages/index.mjs +345 -0
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +11 -11
- package/tools/align.js +8 -0
- package/tools/align.mjs +38 -0
- package/tools/applyColor.js +8 -0
- package/tools/applyColor.mjs +34 -0
- package/tools/cleanFormatting.js +8 -0
- package/tools/cleanFormatting.mjs +41 -0
- package/tools/findReplace.js +8 -0
- package/tools/findReplace.mjs +53 -0
- package/tools/fontStyle.js +8 -0
- package/tools/fontStyle.mjs +61 -0
- package/tools/formatBlock.js +8 -0
- package/tools/formatBlock.mjs +60 -0
- package/tools/history.js +8 -0
- package/tools/history.mjs +17 -0
- package/tools/indent.js +8 -0
- package/tools/indent.mjs +43 -0
- package/tools/index.js +8 -0
- package/tools/index.mjs +278 -0
- package/tools/inlineFormat.js +8 -0
- package/tools/inlineFormat.mjs +43 -0
- package/tools/insertImage.js +8 -0
- package/tools/insertImage.mjs +58 -0
- package/tools/insertLink.js +8 -0
- package/tools/insertLink.mjs +61 -0
- package/tools/insertTable/popup.js +8 -0
- package/tools/insertTable/popup.mjs +94 -0
- package/tools/insertTable/popupGrid.js +8 -0
- package/tools/insertTable/popupGrid.mjs +58 -0
- package/tools/insertTable/tool.js +8 -0
- package/tools/insertTable/tool.mjs +73 -0
- package/tools/lists-styled.js +8 -0
- package/tools/lists-styled.mjs +61 -0
- package/tools/lists.js +8 -0
- package/tools/lists.mjs +47 -0
- package/tools/outdent.js +8 -0
- package/tools/outdent.mjs +43 -0
- package/tools/pdf.js +8 -0
- package/tools/pdf.mjs +36 -0
- package/tools/print.js +8 -0
- package/tools/print.mjs +38 -0
- package/tools/proseMirrorTool.js +8 -0
- package/tools/proseMirrorTool.mjs +37 -0
- package/tools/selectAll.js +8 -0
- package/tools/selectAll.mjs +36 -0
- package/tools/table-wizard/cellPropsUtils.js +8 -0
- package/tools/table-wizard/cellPropsUtils.mjs +124 -0
- package/tools/table-wizard/tableCellProperties.js +8 -0
- package/tools/table-wizard/tableCellProperties.mjs +238 -0
- package/tools/table-wizard/tableProperties.js +8 -0
- package/tools/table-wizard/tableProperties.mjs +292 -0
- package/tools/table-wizard/tablePropsUtils.js +8 -0
- package/tools/table-wizard/tablePropsUtils.mjs +288 -0
- package/tools/table-wizard/utils.js +8 -0
- package/tools/table-wizard/utils.mjs +91 -0
- package/tools/tableEdit.js +8 -0
- package/tools/tableEdit.mjs +36 -0
- package/tools/unlink.js +8 -0
- package/tools/unlink.mjs +41 -0
- package/tools/utils.js +8 -0
- package/tools/utils.mjs +51 -0
- package/tools/viewHtml.js +8 -0
- package/tools/viewHtml.mjs +57 -0
- package/utils/browser-detection.js +8 -0
- package/utils/browser-detection.mjs +12 -0
- package/utils/controlled-value.js +8 -0
- package/utils/controlled-value.mjs +19 -0
- package/utils/index.js +8 -0
- package/utils/index.mjs +162 -0
- package/utils/props-key.js +8 -0
- package/utils/props-key.mjs +13 -0
- package/Editor.d.ts +0 -122
- package/EditorProps.d.ts +0 -200
- package/config/defaultStyles.d.ts +0 -16
- package/config/pasteSettings.d.ts +0 -10
- package/config/schema.d.ts +0 -5
- package/config/shortcuts.d.ts +0 -28
- package/config/toolsSettings.d.ts +0 -493
- package/dialogs/EditorDialogProps.d.ts +0 -30
- package/dialogs/FindReplace.d.ts +0 -75
- package/dialogs/index.d.ts +0 -53
- package/dialogs/insertImage.d.ts +0 -32
- package/dialogs/insertLink.d.ts +0 -30
- package/dialogs/viewHtml.d.ts +0 -29
- package/messages/index.d.ts +0 -338
- package/package-metadata.d.ts +0 -9
- package/tools/ToolProps.d.ts +0 -41
- package/tools/align.d.ts +0 -11
- package/tools/applyColor.d.ts +0 -16
- package/tools/cleanFormatting.d.ts +0 -20
- package/tools/findReplace.d.ts +0 -33
- package/tools/fontStyle.d.ts +0 -32
- package/tools/formatBlock.d.ts +0 -22
- package/tools/history.d.ts +0 -30
- package/tools/indent.d.ts +0 -21
- package/tools/index.d.ts +0 -718
- package/tools/inlineFormat.d.ts +0 -51
- package/tools/insertImage.d.ts +0 -17
- package/tools/insertLink.d.ts +0 -28
- package/tools/insertTable/index.d.ts +0 -7
- package/tools/insertTable/popup.d.ts +0 -97
- package/tools/insertTable/popupGrid.d.ts +0 -35
- package/tools/insertTable/tool.d.ts +0 -28
- package/tools/lists-styled.d.ts +0 -8
- package/tools/lists.d.ts +0 -31
- package/tools/outdent.d.ts +0 -21
- package/tools/pdf.d.ts +0 -29
- package/tools/print.d.ts +0 -20
- package/tools/proseMirrorTool.d.ts +0 -16
- package/tools/selectAll.d.ts +0 -20
- package/tools/table-wizard/cellPropsUtils.d.ts +0 -40
- package/tools/table-wizard/tableCellProperties.d.ts +0 -24
- package/tools/table-wizard/tableProperties.d.ts +0 -15
- package/tools/table-wizard/tablePropsUtils.d.ts +0 -56
- package/tools/table-wizard/utils.d.ts +0 -43
- package/tools/tableEdit.d.ts +0 -102
- package/tools/unlink.d.ts +0 -21
- package/tools/utils.d.ts +0 -54
- package/tools/viewHtml.d.ts +0 -28
- package/utils/browser-detection.d.ts +0 -8
- package/utils/controlled-value.d.ts +0 -9
- package/utils/index.d.ts +0 -367
- package/utils/props-key.d.ts +0 -9
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as e from "react";
|
|
10
|
+
import { Button as A } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { NumericTextBox as s, ColorPicker as se, Checkbox as Ne, TextBox as L } from "@progress/kendo-react-inputs";
|
|
12
|
+
import { AutoComplete as ie, DropDownList as d } from "@progress/kendo-react-dropdowns";
|
|
13
|
+
import { Window as Se, WindowActionsBar as xe } from "@progress/kendo-react-dialogs";
|
|
14
|
+
import { TabStrip as he, TabStripTab as ce } from "@progress/kendo-react-layout";
|
|
15
|
+
import { tablePropertiesIcon as Ce, tablePositionStartIcon as we, tablePositionCenterIcon as ye, tablePositionEndIcon as Re, tableAlignMiddleLeftIcon as Le, tableAlignMiddleCenterIcon as Ae, tableAlignMiddleRightIcon as Ie, tableAlignRemoveIcon as Be, positionTopIcon as Ke, positionBottomIcon as Ve } from "@progress/kendo-svg-icons";
|
|
16
|
+
import { parentNode as Te, onDownPreventDefault as De, units as me, popupSettings as c, borderStyles as ue } from "../utils.mjs";
|
|
17
|
+
import { valueRenderWithIcon as k, itemRenderWithIcon as v } from "./tableCellProperties.mjs";
|
|
18
|
+
import { useLocalization as ge } from "@progress/kendo-react-intl";
|
|
19
|
+
import { keys as t, messages as l } from "../../messages/index.mjs";
|
|
20
|
+
import { applyTableData as ze, tablePositionStyles as He, tableDefaultData as We, initialTableData as Ue } from "./tablePropsUtils.mjs";
|
|
21
|
+
const _e = (o) => {
|
|
22
|
+
const { view: n, ...r } = o, P = ge(), [N, b] = e.useState(!1), g = !!(n && Te(n.state.selection.$from, (i) => i.type.spec.tableRole === "table")), p = e.useCallback(() => {
|
|
23
|
+
b(!0);
|
|
24
|
+
}, []), m = e.useCallback(() => {
|
|
25
|
+
b(!1), n == null || n.focus();
|
|
26
|
+
}, [n]), f = e.useCallback((i) => {
|
|
27
|
+
if (n && i) {
|
|
28
|
+
const u = ze(n.state, i);
|
|
29
|
+
u && n.dispatch(u);
|
|
30
|
+
}
|
|
31
|
+
m();
|
|
32
|
+
}, [n, m]);
|
|
33
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
34
|
+
A,
|
|
35
|
+
{
|
|
36
|
+
type: "button",
|
|
37
|
+
title: P.toLanguageString(t.tableProperties, l[t.tableProperties]),
|
|
38
|
+
icon: "table-properties",
|
|
39
|
+
svgIcon: Ce,
|
|
40
|
+
onClick: p,
|
|
41
|
+
disabled: !g,
|
|
42
|
+
...De,
|
|
43
|
+
...r
|
|
44
|
+
}
|
|
45
|
+
), N && /* @__PURE__ */ e.createElement(Fe, { onClose: m, onSave: f, view: n }));
|
|
46
|
+
}, E = [
|
|
47
|
+
{
|
|
48
|
+
textKey: t.tablePropertiesAlignLeft,
|
|
49
|
+
text: l[t.tablePropertiesAlignLeft],
|
|
50
|
+
value: "left",
|
|
51
|
+
icon: "table-align-middle-left",
|
|
52
|
+
svgIcon: Le
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
textKey: t.tablePropertiesAlignCenter,
|
|
56
|
+
text: l[t.tablePropertiesAlignCenter],
|
|
57
|
+
value: "center",
|
|
58
|
+
icon: "table-align-middle-center",
|
|
59
|
+
svgIcon: Ae
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
textKey: t.tablePropertiesAlignRight,
|
|
63
|
+
text: l[t.tablePropertiesAlignRight],
|
|
64
|
+
value: "right",
|
|
65
|
+
icon: "table-align-middle-right",
|
|
66
|
+
svgIcon: Ie
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
textKey: t.tablePropertiesNoAlignment,
|
|
70
|
+
text: l[t.tablePropertiesNoAlignment],
|
|
71
|
+
value: "",
|
|
72
|
+
icon: "align-remove",
|
|
73
|
+
svgIcon: Be
|
|
74
|
+
}
|
|
75
|
+
], de = [{
|
|
76
|
+
textKey: t.tablePropertiesLeft,
|
|
77
|
+
text: l[t.tablePropertiesLeft],
|
|
78
|
+
value: "left",
|
|
79
|
+
style: {},
|
|
80
|
+
icon: "table-position-left",
|
|
81
|
+
svgIcon: we
|
|
82
|
+
}, {
|
|
83
|
+
textKey: t.tablePropertiesCenter,
|
|
84
|
+
text: l[t.tablePropertiesCenter],
|
|
85
|
+
value: "center",
|
|
86
|
+
style: {},
|
|
87
|
+
icon: "table-position-center",
|
|
88
|
+
svgIcon: ye
|
|
89
|
+
}, {
|
|
90
|
+
textKey: t.tablePropertiesRight,
|
|
91
|
+
text: l[t.tablePropertiesRight],
|
|
92
|
+
value: "right",
|
|
93
|
+
style: {},
|
|
94
|
+
icon: "table-position-right",
|
|
95
|
+
svgIcon: Re
|
|
96
|
+
}].map((o) => ({ ...o, style: He[o.value] })), fe = [{
|
|
97
|
+
textKey: t.tablePropertiesTop,
|
|
98
|
+
text: l[t.tablePropertiesTop],
|
|
99
|
+
value: "top",
|
|
100
|
+
icon: "position-top",
|
|
101
|
+
svgIcon: Ke
|
|
102
|
+
}, {
|
|
103
|
+
textKey: t.tablePropertiesBottom,
|
|
104
|
+
text: l[t.tablePropertiesBottom],
|
|
105
|
+
value: "bottom",
|
|
106
|
+
icon: "position-bottom",
|
|
107
|
+
svgIcon: Ve
|
|
108
|
+
}], be = [
|
|
109
|
+
{ textKey: t.tablePropertiesNone, text: l[t.tablePropertiesNone], value: "none" },
|
|
110
|
+
{ textKey: t.tablePropertiesUsingScopeAttribute, text: l[t.tablePropertiesUsingScopeAttribute], value: "scope" },
|
|
111
|
+
{ textKey: t.tablePropertiesUsingIdAttributes, text: l[t.tablePropertiesUsingIdAttributes], value: "id" }
|
|
112
|
+
], Fe = (o) => {
|
|
113
|
+
const n = e.useMemo(() => {
|
|
114
|
+
const a = o.view && o.view.state;
|
|
115
|
+
return a ? We(a) : Ue;
|
|
116
|
+
}, [o.view]), r = ge(), [P, N] = e.useState(0), b = e.useCallback((a) => {
|
|
117
|
+
N(a.selected);
|
|
118
|
+
}, []), g = e.useRef(null), p = e.useRef(null), m = e.useRef(null), f = e.useRef(null), i = e.useRef(null), u = e.useRef(null), S = e.useRef(null), I = e.useRef(null), B = e.useRef(null), K = e.useRef(null), x = e.useRef(null), h = e.useRef(null), V = e.useRef(null), T = e.useRef(null), D = e.useRef(null), z = e.useRef(null), H = e.useRef(null), W = e.useRef(null), U = e.useRef(null), F = e.useRef(null), C = e.useRef(null), w = e.useRef(null), y = e.useRef(null), pe = e.useCallback(() => {
|
|
119
|
+
var R, M, G, $, j, q, J, O, Q, X, Y, Z, _, ee, te, ae, le, re, ne, oe;
|
|
120
|
+
const a = {
|
|
121
|
+
rows: ((R = g.current) == null ? void 0 : R.value) || 0,
|
|
122
|
+
columns: ((M = p.current) == null ? void 0 : M.value) || 0,
|
|
123
|
+
width: m.current ? m.current.value : null,
|
|
124
|
+
height: f.current ? f.current.value : null,
|
|
125
|
+
cellSpacing: i.current ? i.current.value : null,
|
|
126
|
+
cellPadding: u.current ? u.current.value : null,
|
|
127
|
+
borderWidth: S.current ? S.current.value : null,
|
|
128
|
+
widthUnit: ((G = I.current) == null ? void 0 : G.value) || "",
|
|
129
|
+
heightUnit: (($ = B.current) == null ? void 0 : $.value) || "",
|
|
130
|
+
position: ((q = (j = K.current) == null ? void 0 : j.value) == null ? void 0 : q.value) || null,
|
|
131
|
+
textAlign: (J = x.current) != null && J.value ? x.current.value.value : null,
|
|
132
|
+
borderStyle: (O = h.current) != null && O.value ? h.current.value.value : null,
|
|
133
|
+
backgroundColor: (Q = V.current) == null ? void 0 : Q.value,
|
|
134
|
+
borderColor: (X = T.current) == null ? void 0 : X.value,
|
|
135
|
+
collapseBorders: !!((Z = (Y = D.current) == null ? void 0 : Y.element) != null && Z.checked),
|
|
136
|
+
id: String(((_ = z.current) == null ? void 0 : _.value) || ""),
|
|
137
|
+
className: String(((ee = H.current) == null ? void 0 : ee.value) || ""),
|
|
138
|
+
caption: String(((te = W.current) == null ? void 0 : te.value) || ""),
|
|
139
|
+
headerRows: ((ae = U.current) == null ? void 0 : ae.value) || 0,
|
|
140
|
+
headerColumns: ((le = F.current) == null ? void 0 : le.value) || 0,
|
|
141
|
+
captionAlignment: (re = C.current) != null && re.value ? C.current.value.value : null,
|
|
142
|
+
captionPosition: (ne = w.current) != null && ne.value ? w.current.value.value : null,
|
|
143
|
+
associateHeaders: (oe = y.current) != null && oe.value ? y.current.value.value : "none"
|
|
144
|
+
};
|
|
145
|
+
o.onSave.call(void 0, a);
|
|
146
|
+
}, [o.onSave]), ke = /* @__PURE__ */ e.createElement("div", { className: "k-form k-form-md" }, /* @__PURE__ */ e.createElement("fieldset", { className: "k-form-fieldset" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-layout k-d-grid k-grid-cols-4 k-gap-x-4" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesRows, l[t.tablePropertiesRows])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: g, defaultValue: n.rows, min: 1 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesColumns, l[t.tablePropertiesColumns])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: p, defaultValue: n.columns, min: 1 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesWidth, l[t.tablePropertiesWidth])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
147
|
+
s,
|
|
148
|
+
{
|
|
149
|
+
ref: m,
|
|
150
|
+
defaultValue: n.width,
|
|
151
|
+
min: 0,
|
|
152
|
+
placeholder: r.toLanguageString(t.sizeAuto, l[t.sizeAuto])
|
|
153
|
+
}
|
|
154
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, " "), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
155
|
+
ie,
|
|
156
|
+
{
|
|
157
|
+
ref: I,
|
|
158
|
+
defaultValue: n.widthUnit,
|
|
159
|
+
data: me,
|
|
160
|
+
popupSettings: c
|
|
161
|
+
}
|
|
162
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesHeight, l[t.tablePropertiesHeight])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
163
|
+
s,
|
|
164
|
+
{
|
|
165
|
+
ref: f,
|
|
166
|
+
defaultValue: n.height,
|
|
167
|
+
min: 0,
|
|
168
|
+
placeholder: r.toLanguageString(t.sizeAuto, l[t.sizeAuto])
|
|
169
|
+
}
|
|
170
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, " "), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
171
|
+
ie,
|
|
172
|
+
{
|
|
173
|
+
ref: B,
|
|
174
|
+
defaultValue: n.heightUnit,
|
|
175
|
+
data: me.filter((a) => a !== "%"),
|
|
176
|
+
popupSettings: c
|
|
177
|
+
}
|
|
178
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesPosition, l[t.tablePropertiesPosition])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
179
|
+
d,
|
|
180
|
+
{
|
|
181
|
+
ref: K,
|
|
182
|
+
defaultValue: de.find((a) => a.value === n.position),
|
|
183
|
+
popupSettings: c,
|
|
184
|
+
data: de.map((a) => ({ ...a, text: r.toLanguageString(a.textKey, a.text) })),
|
|
185
|
+
textField: "text",
|
|
186
|
+
dataItemKey: "value",
|
|
187
|
+
valueRender: k,
|
|
188
|
+
itemRender: v
|
|
189
|
+
}
|
|
190
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesAlignment, l[t.tablePropertiesAlignment])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
191
|
+
d,
|
|
192
|
+
{
|
|
193
|
+
ref: x,
|
|
194
|
+
defaultValue: E.find((a) => a.value === n.textAlign),
|
|
195
|
+
data: E.map((a) => ({ ...a, text: r.toLanguageString(a.textKey, a.text) })),
|
|
196
|
+
textField: "text",
|
|
197
|
+
dataItemKey: "value",
|
|
198
|
+
popupSettings: c,
|
|
199
|
+
valueRender: k,
|
|
200
|
+
itemRender: v
|
|
201
|
+
}
|
|
202
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesCellSpacing, l[t.tablePropertiesCellSpacing])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
203
|
+
s,
|
|
204
|
+
{
|
|
205
|
+
ref: i,
|
|
206
|
+
defaultValue: n.cellSpacing,
|
|
207
|
+
placeholder: r.toLanguageString(t.sizeAuto, l[t.sizeAuto]),
|
|
208
|
+
min: 0
|
|
209
|
+
}
|
|
210
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesCellPadding, l[t.tablePropertiesCellPadding])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
211
|
+
s,
|
|
212
|
+
{
|
|
213
|
+
ref: u,
|
|
214
|
+
defaultValue: n.cellPadding,
|
|
215
|
+
placeholder: r.toLanguageString(t.sizeAuto, l[t.sizeAuto]),
|
|
216
|
+
min: 0
|
|
217
|
+
}
|
|
218
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-full" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesTableBackground, l[t.tablePropertiesTableBackground])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(se, { ref: V, defaultValue: n.backgroundColor }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesBorderWidth, l[t.tablePropertiesBorderWidth])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: S, defaultValue: n.borderWidth, min: 0 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesBorderColor, l[t.tablePropertiesBorderColor])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(se, { ref: T, defaultValue: n.borderColor }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesBorderStyle, l[t.tablePropertiesBorderStyle])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
219
|
+
d,
|
|
220
|
+
{
|
|
221
|
+
ref: h,
|
|
222
|
+
defaultValue: ue.find((a) => a.value === n.borderStyle),
|
|
223
|
+
popupSettings: c,
|
|
224
|
+
data: ue.map((a) => ({ ...a, text: r.toLanguageString(a.textKey, a.text) })),
|
|
225
|
+
textField: "text",
|
|
226
|
+
dataItemKey: "value"
|
|
227
|
+
}
|
|
228
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-full" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
229
|
+
Ne,
|
|
230
|
+
{
|
|
231
|
+
ref: D,
|
|
232
|
+
className: "k-checkbox-wrap",
|
|
233
|
+
label: r.toLanguageString(t.tablePropertiesCollapseBorders, l[t.tablePropertiesCollapseBorders]),
|
|
234
|
+
defaultChecked: n.collapseBorders
|
|
235
|
+
}
|
|
236
|
+
)))))), ve = /* @__PURE__ */ e.createElement("div", { className: "k-form k-form-md" }, /* @__PURE__ */ e.createElement("fieldset", { className: "k-form-fieldset" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-layout k-d-grid" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-field" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesId, l[t.tablePropertiesId])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(L, { ref: z, defaultValue: n.id }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesCssClass, l[t.tablePropertiesCssClass])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(L, { ref: H, defaultValue: n.className }))), /* @__PURE__ */ e.createElement("fieldset", { className: "k-form-fieldset" }, /* @__PURE__ */ e.createElement("legend", { className: "k-form-legend" }, r.toLanguageString(t.tablePropertiesAccessibility, l[t.tablePropertiesAccessibility])), /* @__PURE__ */ e.createElement("div", { className: "k-d-grid k-grid-cols-4 k-gap-x-4" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-full" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesCaption, l[t.tablePropertiesCaption])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(L, { ref: W, defaultValue: n.caption }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesCaptionPosition, l[t.tablePropertiesCaptionPosition])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
237
|
+
d,
|
|
238
|
+
{
|
|
239
|
+
ref: w,
|
|
240
|
+
defaultValue: fe.find((a) => a.value === n.captionPosition),
|
|
241
|
+
data: fe.map((a) => ({ ...a, text: r.toLanguageString(a.textKey, a.text) })),
|
|
242
|
+
popupSettings: c,
|
|
243
|
+
textField: "text",
|
|
244
|
+
dataItemKey: "value",
|
|
245
|
+
valueRender: k,
|
|
246
|
+
itemRender: v
|
|
247
|
+
}
|
|
248
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesCaptionAlignment, l[t.tablePropertiesCaptionAlignment])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
249
|
+
d,
|
|
250
|
+
{
|
|
251
|
+
ref: C,
|
|
252
|
+
defaultValue: E.find((a) => a.value === n.captionAlignment),
|
|
253
|
+
data: E.map((a) => ({ ...a, text: r.toLanguageString(a.textKey, a.text) })),
|
|
254
|
+
popupSettings: c,
|
|
255
|
+
textField: "text",
|
|
256
|
+
dataItemKey: "value",
|
|
257
|
+
valueRender: k,
|
|
258
|
+
itemRender: v
|
|
259
|
+
}
|
|
260
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesHeaderRows, l[t.tablePropertiesHeaderRows])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: U, defaultValue: n.headerRows, min: 0 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesHeaderCols, l[t.tablePropertiesHeaderCols])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: F, defaultValue: n.headerColumns, min: 0 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesAssociateHeaders, l[t.tablePropertiesAssociateHeaders])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
261
|
+
d,
|
|
262
|
+
{
|
|
263
|
+
ref: y,
|
|
264
|
+
defaultValue: be.find((a) => a.value === n.associateHeaders),
|
|
265
|
+
data: be.map((a) => ({ ...a, text: r.toLanguageString(a.textKey, a.text) })),
|
|
266
|
+
popupSettings: c,
|
|
267
|
+
textField: "text",
|
|
268
|
+
dataItemKey: "value"
|
|
269
|
+
}
|
|
270
|
+
)))))))), Ee = /* @__PURE__ */ e.createElement(he, { selected: P, onSelect: b, animation: !1, keepTabsMounted: !0 }, /* @__PURE__ */ e.createElement(ce, { title: r.toLanguageString(t.tablePropertiesGeneral, l[t.tablePropertiesGeneral]) }, ke), /* @__PURE__ */ e.createElement(ce, { title: r.toLanguageString(t.tablePropertiesAdvanced, l[t.tablePropertiesAdvanced]) }, ve)), Pe = [/* @__PURE__ */ e.createElement(A, { themeColor: "primary", key: "save", onClick: pe }, r.toLanguageString(t.tablePropertiesSave, l[t.tablePropertiesSave])), /* @__PURE__ */ e.createElement(A, { onClick: o.onClose, key: "cancel" }, r.toLanguageString(t.tablePropertiesCancel, l[t.tablePropertiesCancel]))];
|
|
271
|
+
return /* @__PURE__ */ e.createElement(
|
|
272
|
+
Se,
|
|
273
|
+
{
|
|
274
|
+
className: "k-editor-window k-editor-table-wizard-window",
|
|
275
|
+
title: r.toLanguageString(t.tableProperties, l[t.tableProperties]),
|
|
276
|
+
onClose: o.onClose,
|
|
277
|
+
key: "dialog",
|
|
278
|
+
style: { userSelect: "none" },
|
|
279
|
+
width: 480,
|
|
280
|
+
height: 630,
|
|
281
|
+
modal: !0,
|
|
282
|
+
minimizeButton: () => null,
|
|
283
|
+
maximizeButton: () => null,
|
|
284
|
+
resizable: !1
|
|
285
|
+
},
|
|
286
|
+
Ee,
|
|
287
|
+
/* @__PURE__ */ e.createElement(xe, { layout: "start" }, ...Pe)
|
|
288
|
+
);
|
|
289
|
+
};
|
|
290
|
+
export {
|
|
291
|
+
_e as TableProperties
|
|
292
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@progress/kendo-editor-common"),k=require("../tableEdit.js"),d=require("./utils.js"),N=require("../utils.js"),E={rows:0,columns:0,width:null,widthUnit:"",height:null,heightUnit:"",position:null,textAlign:"",cellPadding:null,cellSpacing:null,backgroundColor:void 0,borderWidth:null,borderColor:void 0,borderStyle:null,collapseBorders:!1,id:"",className:"",caption:"",captionAlignment:null,captionPosition:null,headerRows:0,headerColumns:0,associateHeaders:"none"},A={left:{"margin-left":"","margin-right":"auto"},center:{"margin-left":"auto","margin-right":"auto"},right:{"margin-left":"auto","margin-right":""},"":{}},M=o=>{const t=[];for(let s=0;s<o.height;s++){const l=s*o.width,e=l+o.width;t.push(o.map.slice(l,e))}return t},$=(o,t)=>{let s=0,l=0;const e=M(t);e.forEach(n=>{let i=!0;n.forEach(r=>{const c=o.nodeAt(r);c&&c.type.name!=="table_header"&&(i=!1)}),i&&s++});for(let n=0;n<t.width;n++){let i=!0;for(let r=0;r<t.height;r++){const c=e[r]&&e[r][n],u=typeof c=="number"&&o.nodeAt(c);u&&u.type.name!=="table_header"&&(i=!1)}i&&l++}return{rows:s,columns:l}},v=o=>{const t=new Set;return o.content.forEach(s=>{s.content.forEach(l=>{t.add(d.parseStyle(l.attrs.style).padding||"")})}),t.size===1?Array.from(t)[0]:""},j=o=>{let t=!0,s=!0;return o.content.forEach(l=>{l.content.forEach(e=>{let n=e.type.name==="table_header",i=e.type.name==="table_cell";n&&!e.attrs.scope&&(t=!1),(n&&!e.attrs.id||i&&!e.attrs.headers)&&(s=!1)})}),t?"scope":s?"id":"none"},F=o=>{var a,h,m;const t=d.selectedCells(o),s=o.selection.$from,l=t.length?N.parentNode(s,f=>f.type.spec.tableRole==="table"):null;if(!l)return E;const e=N.parentNode(s,f=>f.type.name==="table_wrapper");let n="",i={},r={};e&&(r=d.parseStyle(e.node.attrs.style),e.node.content.forEach(f=>{if(f.type.name==="table_caption_external"){const S=w.pmDocToFragment(f);n=w.fragmentToHtml(S),n=n==="<img>"?"":n,i=d.parseStyle(f.attrs.style)}}));const c=d.parseStyle(((a=l.node.attrs)==null?void 0:a.style)||""),u=w.TableMap.get(l.node),p=r["margin-left"]==="auto"&&r["margin-right"]==="auto"?"center":r["margin-right"]==="auto"?"left":r["margin-left"]==="auto"?"right":null,y=$(l.node,u),g=v(l.node);return{...E,columns:u.width,rows:u.height,...d.nodeSize(l.node,"width"),...e&&/%/.test(r.width||"")?d.nodeSize(e.node,"width"):{},...d.nodeSize(l.node,"height"),textAlign:c["text-align"]||"",position:p||null,cellPadding:g?parseFloat(g):null,cellSpacing:c["border-spacing"]?parseFloat(c["border-spacing"]):null,backgroundColor:c["background-color"],borderWidth:c["border-width"]?parseFloat(c["border-width"]):null,borderColor:c["border-color"],borderStyle:c["border-style"]||null,collapseBorders:c["border-collapse"]==="collapse",caption:n||void 0,captionAlignment:i["text-align"]||"",captionPosition:i["caption-side"]||null,headerRows:y.rows,headerColumns:y.columns,associateHeaders:y.rows||y.columns?j(l.node):"none",id:((h=l.node.attrs)==null?void 0:h.id)||"",className:((m=l.node.attrs)==null?void 0:m.class)||""}},x=o=>{const s=o.lastChild.lastChild;return{node:s,pos:o.content.size-s.nodeSize}},_=(o,t,s,l,e)=>{const n=x(s),i=t+n.pos;if(!o.doc.nodeAt(i))return o;const c=o.doc.resolve(i),u=new w.CellSelection(c,c),p=o.tr.setSelection(u);let y=o.apply(p);for(let g=0;g<l;g++)e(y,a=>{y=y.apply(a)});return y},R=(o,t,s,l)=>{let e=o;for(let n=0;n<s;n++){const i=e.doc.nodeAt(t);if(i){const r=x(i),c=t+r.pos,u=e.doc.resolve(c),p=new w.CellSelection(u,u),y=e.tr.setSelection(p);e=e.apply(y),l(e,g=>{e=e.apply(g)})}}return e},O=(o,t,s,l)=>{let e=o,n=e.doc.nodeAt(t);if(!n)return e;let i=w.TableMap.get(n);return i.width===l&&i.height===s||(l>i.width?e=_(e,t,n,l-i.width,w.addColumnAfter):l<i.width&&(e=R(e,t,i.width-l,k.deleteColumnCmd)),n=e.doc.nodeAt(t),!n)||(i=w.TableMap.get(n),s>i.height?e=_(e,t,n,s-i.height,w.addRowAfter):s<i.height&&(e=R(e,t,i.height-s,k.deleteRowCmd))),e},q=(o,t,s)=>{const l=o.doc.nodeAt(s);if(!l)return o;let e={...l.attrs};const n=t.width!==null&&(t.widthUnit!=="%"||!t.caption&&!t.position);e=d.setNodeStyle(e,"width",n?t.width+t.widthUnit:""),e=d.setNodeStyle(e,"height",t.height!==null?t.height+t.heightUnit:""),e=d.setNodeStyle(e,"text-align",t.textAlign||""),e=d.setNodeStyle(e,"background-color",t.backgroundColor||""),e=d.setNodeStyle(e,"border-width",t.borderWidth?t.borderWidth+"px":""),e=d.setNodeStyle(e,"border-style",t.borderStyle||""),e=d.setNodeStyle(e,"border-color",t.borderColor||""),e=d.setNodeStyle(e,"border-spacing",t.cellSpacing!==null?t.cellSpacing+"px":""),t.cellSpacing!==null?e=d.setNodeStyle(e,"border-collapse","unset"):e=d.setNodeStyle(e,"border-collapse",t.collapseBorders?"collapse":"");const i=A[t.position||""]||{};Object.keys(i).forEach(c=>{e=d.setNodeStyle(e,c,i[c])}),e.id=t.id||null,e.class=t.className||null;const r=o.tr.setNodeMarkup(s,null,e);return o=o.apply(r),o},z=(o,t,s,l,e)=>{if(t.type.name!==l.name||Object.keys(e).length>0){const n=o.tr.setNodeMarkup(s,l,{...t.attrs,...e});return o.apply(n)}return o},B=(o,t)=>{/^cell-[0-9]+-[0-9]+$/.test(o.attrs.id||"")&&(t.id=null)},P=(o,t,s)=>{const l=o.doc.nodeAt(s),e=l&&w.TableMap.get(l);if(!l||!e)return o;const n=M(e);let i=o;const{table_header:r,table_cell:c}=o.schema.nodes,u=String(new Date().getTime()),p=[],y=(a,h)=>{const m=`cell-${a}${h}-${u}`;return p[a]||p.push([]),p[a][h]||p[a].push([]),p[a][h]=m,m},g=(a,h,m,f)=>{const S=[];if(f)for(let b=0;b<a;b++)p[b]&&p[b][h]&&S.push(p[b][h]);if(m)for(let b=0;b<h;b++)p[a]&&p[a][b]&&S.push(p[a][b]);return S.join(" ")};return n.forEach((a,h)=>{a.forEach((m,f)=>{const S=l.nodeAt(m);if(S){const b=f<t.headerColumns,T=h<t.headerRows,C={...S.attrs};B(S,C),C.headers=null,C.scope=null,T||b?(t.associateHeaders==="scope"&&(C.scope=T?"col":"row"),t.associateHeaders==="id"&&(C.id=y(h,f),(f>0||h>0)&&(C.headers=g(h,f,b,T)||null)),i=z(i,S,s+m+1,r,C)):(t.associateHeaders==="id"&&(C.headers=g(h,f,t.headerColumns>0,t.headerRows>0)||null),i=z(i,S,s+m+1,c,C))}})}),i},G=(o,t,s,l)=>{let e={...t.attrs};return e=d.setNodeStyle(e,"margin-left",""),e=d.setNodeStyle(e,"margin-right",""),Object.keys(l||{}).forEach(n=>{e=d.setNodeStyle(e,n,(l||{})[n]||"")}),o.apply(o.tr.setNodeMarkup(s,null,e))},D=(o,t)=>w.parseContent("<p>"+o+"</p>",t).content.firstChild.content,H=(o,t)=>{if(!o.caption)return;let s={caption:"",style:"display: table-caption"};o.captionAlignment&&(s=d.setNodeStyle(s,"text-align",o.captionAlignment)),o.captionPosition&&(s=d.setNodeStyle(s,"caption-side",o.captionPosition));const l=D(o.caption,t);return l&&t.nodes.table_caption_external.createAndFill(s,l)||void 0},U=o=>o.firstChild&&o.firstChild.type.name==="table_caption_external",J=(o,t,s,l)=>{let e=o,n;const i=s+2,r=s+1,c=e.schema;if(U(t))if(n=t.firstChild,l.caption){const u=D(l.caption,c);if(e=e.apply(e.tr.replaceWith(i,i+n.content.size,u)),n=e.doc.nodeAt(r),n){let p={...n.attrs};p=d.setNodeStyle(p,"text-align",l.captionAlignment||""),p=d.setNodeStyle(p,"caption-side",l.captionPosition||""),e=e.apply(e.tr.setNodeAttribute(r,"style",p.style))}}else e=e.apply(e.tr.deleteRange(i,i+n.content.size));else n=H(l,c),n&&(e=e.apply(e.tr.replaceWith(r,r,n)));return e},K=(o,t,s,l,e)=>{let n={state:o,pos:s};if(!l&&(t.position||t.caption)){let r={table:"",style:"display: table"};const c=[],u=t.position,p=u&&A[u];p&&Object.keys(p).forEach(h=>{r=d.setNodeStyle(r,h,p[h]||"")}),typeof t.width=="number"&&t.widthUnit==="%"&&(r=d.setNodeStyle(r,"width",t.width+t.widthUnit));const y=H(t,o.schema);y&&c.push(y);const g=o.doc.nodeAt(s);c.push(g);const a=o.schema.nodes.table_wrapper.createAndFill(r,c);if(a){const h=o.tr.replaceWith(s,s+g.content.size,a);o=o.apply(h),n={state:o,pos:s}}}else l&&(t.position||t.caption||!t.caption&&U(l.node))?(o=G(o,l.node,e,t.position&&A[t.position]),o=J(o,l.node,e,t),n={state:o,pos:e}):l&&!(t.position||t.caption)?n={state:o,node:l.node,pos:o.selection.$from.start(l.depth)-1}:n={state:o,pos:s};const i=l&&n.state.doc.nodeAt(e);if(i){let r;typeof t.width=="number"&&t.widthUnit==="%"?r=d.setNodeStyle(i.attrs,"width",t.width+t.widthUnit):t.widthUnit!=="%"&&/%/.test(d.parseStyle(i.attrs.style||"").width||"")&&(r=d.setNodeStyle(i.attrs,"width","")),r&&(n.state=n.state.apply(n.state.tr.setNodeMarkup(e,null,r)))}return n},L=(o,t)=>{const s=o.selection.$from;let l=N.parentNode(s,f=>f.type.spec.tableRole==="table");if(!l)return;const e=s.start(l.depth)-1;let n=O(o,e,t.rows,t.columns);if(!n)return;const i=n.tr;d.tableCells(n).forEach(f=>{let S={...f.node.attrs};S=d.setNodeStyle(S,"padding",typeof t.cellPadding=="number"?t.cellPadding+"px":""),i.setNodeMarkup(f.pos,null,S)}),n=n.apply(i),n=q(n,t,e),n=P(n,t,e);const r=N.parentNode(s,f=>f.type.name==="table_wrapper"),c=s.start((r==null?void 0:r.depth)||0)-1;let u=K(n,t,e,r,c);n=u.state;const p=u.pos,y=n.doc.nodeAt(u.pos);if(!y)return;const g=p+(r||l).node.content.size,a=o.tr.replaceWith(p,g,y),h=w.Selection.atEnd(y),m=w.TextSelection.create(a.doc,p+h.to+1);return a.setSelection(m),a};exports.applyTableData=L;exports.initialTableData=E;exports.tableDefaultData=F;exports.tablePositionStyles=A;
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import { pmDocToFragment as F, fragmentToHtml as j, TableMap as A, Selection as O, TextSelection as B, CellSelection as U, addColumnAfter as q, addRowAfter as G, parseContent as J } from "@progress/kendo-editor-common";
|
|
10
|
+
import { deleteColumnCmd as K, deleteRowCmd as L } from "../tableEdit.mjs";
|
|
11
|
+
import { selectedCells as P, parseStyle as S, nodeSize as _, tableCells as Q, setNodeStyle as h } from "./utils.mjs";
|
|
12
|
+
import { parentNode as T } from "../utils.mjs";
|
|
13
|
+
const N = {
|
|
14
|
+
rows: 0,
|
|
15
|
+
columns: 0,
|
|
16
|
+
width: null,
|
|
17
|
+
widthUnit: "",
|
|
18
|
+
height: null,
|
|
19
|
+
heightUnit: "",
|
|
20
|
+
position: null,
|
|
21
|
+
textAlign: "",
|
|
22
|
+
cellPadding: null,
|
|
23
|
+
cellSpacing: null,
|
|
24
|
+
backgroundColor: void 0,
|
|
25
|
+
borderWidth: null,
|
|
26
|
+
borderColor: void 0,
|
|
27
|
+
borderStyle: null,
|
|
28
|
+
collapseBorders: !1,
|
|
29
|
+
id: "",
|
|
30
|
+
className: "",
|
|
31
|
+
caption: "",
|
|
32
|
+
captionAlignment: null,
|
|
33
|
+
captionPosition: null,
|
|
34
|
+
headerRows: 0,
|
|
35
|
+
headerColumns: 0,
|
|
36
|
+
associateHeaders: "none"
|
|
37
|
+
}, k = {
|
|
38
|
+
left: { "margin-left": "", "margin-right": "auto" },
|
|
39
|
+
center: { "margin-left": "auto", "margin-right": "auto" },
|
|
40
|
+
right: { "margin-left": "auto", "margin-right": "" },
|
|
41
|
+
"": {}
|
|
42
|
+
}, z = (n) => {
|
|
43
|
+
const t = [];
|
|
44
|
+
for (let i = 0; i < n.height; i++) {
|
|
45
|
+
const l = i * n.width, e = l + n.width;
|
|
46
|
+
t.push(n.map.slice(l, e));
|
|
47
|
+
}
|
|
48
|
+
return t;
|
|
49
|
+
}, V = (n, t) => {
|
|
50
|
+
let i = 0, l = 0;
|
|
51
|
+
const e = z(t);
|
|
52
|
+
e.forEach((o) => {
|
|
53
|
+
let s = !0;
|
|
54
|
+
o.forEach((r) => {
|
|
55
|
+
const c = n.nodeAt(r);
|
|
56
|
+
c && c.type.name !== "table_header" && (s = !1);
|
|
57
|
+
}), s && i++;
|
|
58
|
+
});
|
|
59
|
+
for (let o = 0; o < t.width; o++) {
|
|
60
|
+
let s = !0;
|
|
61
|
+
for (let r = 0; r < t.height; r++) {
|
|
62
|
+
const c = e[r] && e[r][o], u = typeof c == "number" && n.nodeAt(c);
|
|
63
|
+
u && u.type.name !== "table_header" && (s = !1);
|
|
64
|
+
}
|
|
65
|
+
s && l++;
|
|
66
|
+
}
|
|
67
|
+
return { rows: i, columns: l };
|
|
68
|
+
}, X = (n) => {
|
|
69
|
+
const t = /* @__PURE__ */ new Set();
|
|
70
|
+
return n.content.forEach((i) => {
|
|
71
|
+
i.content.forEach((l) => {
|
|
72
|
+
t.add(S(l.attrs.style).padding || "");
|
|
73
|
+
});
|
|
74
|
+
}), t.size === 1 ? Array.from(t)[0] : "";
|
|
75
|
+
}, Y = (n) => {
|
|
76
|
+
let t = !0, i = !0;
|
|
77
|
+
return n.content.forEach((l) => {
|
|
78
|
+
l.content.forEach((e) => {
|
|
79
|
+
let o = e.type.name === "table_header", s = e.type.name === "table_cell";
|
|
80
|
+
o && !e.attrs.scope && (t = !1), (o && !e.attrs.id || s && !e.attrs.headers) && (i = !1);
|
|
81
|
+
});
|
|
82
|
+
}), t ? "scope" : i ? "id" : "none";
|
|
83
|
+
}, ce = (n) => {
|
|
84
|
+
var p, a, b;
|
|
85
|
+
const t = P(n), i = n.selection.$from, l = t.length ? T(i, (f) => f.type.spec.tableRole === "table") : null;
|
|
86
|
+
if (!l)
|
|
87
|
+
return N;
|
|
88
|
+
const e = T(i, (f) => f.type.name === "table_wrapper");
|
|
89
|
+
let o = "", s = {}, r = {};
|
|
90
|
+
e && (r = S(e.node.attrs.style), e.node.content.forEach((f) => {
|
|
91
|
+
if (f.type.name === "table_caption_external") {
|
|
92
|
+
const y = F(f);
|
|
93
|
+
o = j(y), o = o === "<img>" ? "" : o, s = S(f.attrs.style);
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
const c = S(((p = l.node.attrs) == null ? void 0 : p.style) || ""), u = A.get(l.node), d = r["margin-left"] === "auto" && r["margin-right"] === "auto" ? "center" : r["margin-right"] === "auto" ? "left" : r["margin-left"] === "auto" ? "right" : null, g = V(l.node, u), m = X(l.node);
|
|
97
|
+
return {
|
|
98
|
+
...N,
|
|
99
|
+
columns: u.width,
|
|
100
|
+
rows: u.height,
|
|
101
|
+
..._(l.node, "width"),
|
|
102
|
+
...e && /%/.test(r.width || "") ? _(e.node, "width") : {},
|
|
103
|
+
..._(l.node, "height"),
|
|
104
|
+
textAlign: c["text-align"] || "",
|
|
105
|
+
position: d || null,
|
|
106
|
+
cellPadding: m ? parseFloat(m) : null,
|
|
107
|
+
cellSpacing: c["border-spacing"] ? parseFloat(c["border-spacing"]) : null,
|
|
108
|
+
backgroundColor: c["background-color"],
|
|
109
|
+
borderWidth: c["border-width"] ? parseFloat(c["border-width"]) : null,
|
|
110
|
+
borderColor: c["border-color"],
|
|
111
|
+
borderStyle: c["border-style"] || null,
|
|
112
|
+
collapseBorders: c["border-collapse"] === "collapse",
|
|
113
|
+
caption: o || void 0,
|
|
114
|
+
captionAlignment: s["text-align"] || "",
|
|
115
|
+
captionPosition: s["caption-side"] || null,
|
|
116
|
+
headerRows: g.rows,
|
|
117
|
+
headerColumns: g.columns,
|
|
118
|
+
associateHeaders: g.rows || g.columns ? Y(l.node) : "none",
|
|
119
|
+
id: ((a = l.node.attrs) == null ? void 0 : a.id) || "",
|
|
120
|
+
className: ((b = l.node.attrs) == null ? void 0 : b.class) || ""
|
|
121
|
+
};
|
|
122
|
+
}, $ = (n) => {
|
|
123
|
+
const i = n.lastChild.lastChild;
|
|
124
|
+
return { node: i, pos: n.content.size - i.nodeSize };
|
|
125
|
+
}, R = (n, t, i, l, e) => {
|
|
126
|
+
const o = $(i), s = t + o.pos;
|
|
127
|
+
if (!n.doc.nodeAt(s))
|
|
128
|
+
return n;
|
|
129
|
+
const c = n.doc.resolve(s), u = new U(c, c), d = n.tr.setSelection(u);
|
|
130
|
+
let g = n.apply(d);
|
|
131
|
+
for (let m = 0; m < l; m++)
|
|
132
|
+
e(g, (p) => {
|
|
133
|
+
g = g.apply(p);
|
|
134
|
+
});
|
|
135
|
+
return g;
|
|
136
|
+
}, x = (n, t, i, l) => {
|
|
137
|
+
let e = n;
|
|
138
|
+
for (let o = 0; o < i; o++) {
|
|
139
|
+
const s = e.doc.nodeAt(t);
|
|
140
|
+
if (s) {
|
|
141
|
+
const r = $(s), c = t + r.pos, u = e.doc.resolve(c), d = new U(u, u), g = e.tr.setSelection(d);
|
|
142
|
+
e = e.apply(g), l(e, (m) => {
|
|
143
|
+
e = e.apply(m);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return e;
|
|
148
|
+
}, Z = (n, t, i, l) => {
|
|
149
|
+
let e = n, o = e.doc.nodeAt(t);
|
|
150
|
+
if (!o)
|
|
151
|
+
return e;
|
|
152
|
+
let s = A.get(o);
|
|
153
|
+
return s.width === l && s.height === i || (l > s.width ? e = R(e, t, o, l - s.width, q) : l < s.width && (e = x(e, t, s.width - l, K)), o = e.doc.nodeAt(t), !o) || (s = A.get(o), i > s.height ? e = R(e, t, o, i - s.height, G) : i < s.height && (e = x(e, t, s.height - i, L))), e;
|
|
154
|
+
}, W = (n, t, i) => {
|
|
155
|
+
const l = n.doc.nodeAt(i);
|
|
156
|
+
if (!l)
|
|
157
|
+
return n;
|
|
158
|
+
let e = { ...l.attrs };
|
|
159
|
+
const o = t.width !== null && (t.widthUnit !== "%" || !t.caption && !t.position);
|
|
160
|
+
e = h(e, "width", o ? t.width + t.widthUnit : ""), e = h(e, "height", t.height !== null ? t.height + t.heightUnit : ""), e = h(e, "text-align", t.textAlign || ""), e = h(e, "background-color", t.backgroundColor || ""), e = h(e, "border-width", t.borderWidth ? t.borderWidth + "px" : ""), e = h(e, "border-style", t.borderStyle || ""), e = h(e, "border-color", t.borderColor || ""), e = h(e, "border-spacing", t.cellSpacing !== null ? t.cellSpacing + "px" : ""), t.cellSpacing !== null ? e = h(e, "border-collapse", "unset") : e = h(e, "border-collapse", t.collapseBorders ? "collapse" : "");
|
|
161
|
+
const s = k[t.position || ""] || {};
|
|
162
|
+
Object.keys(s).forEach((c) => {
|
|
163
|
+
e = h(e, c, s[c]);
|
|
164
|
+
}), e.id = t.id || null, e.class = t.className || null;
|
|
165
|
+
const r = n.tr.setNodeMarkup(i, null, e);
|
|
166
|
+
return n = n.apply(r), n;
|
|
167
|
+
}, H = (n, t, i, l, e) => {
|
|
168
|
+
if (t.type.name !== l.name || Object.keys(e).length > 0) {
|
|
169
|
+
const o = n.tr.setNodeMarkup(i, l, { ...t.attrs, ...e });
|
|
170
|
+
return n.apply(o);
|
|
171
|
+
}
|
|
172
|
+
return n;
|
|
173
|
+
}, I = (n, t) => {
|
|
174
|
+
/^cell-[0-9]+-[0-9]+$/.test(n.attrs.id || "") && (t.id = null);
|
|
175
|
+
}, ee = (n, t, i) => {
|
|
176
|
+
const l = n.doc.nodeAt(i), e = l && A.get(l);
|
|
177
|
+
if (!l || !e)
|
|
178
|
+
return n;
|
|
179
|
+
const o = z(e);
|
|
180
|
+
let s = n;
|
|
181
|
+
const { table_header: r, table_cell: c } = n.schema.nodes, u = String((/* @__PURE__ */ new Date()).getTime()), d = [], g = (p, a) => {
|
|
182
|
+
const b = `cell-${p}${a}-${u}`;
|
|
183
|
+
return d[p] || d.push([]), d[p][a] || d[p].push([]), d[p][a] = b, b;
|
|
184
|
+
}, m = (p, a, b, f) => {
|
|
185
|
+
const y = [];
|
|
186
|
+
if (f)
|
|
187
|
+
for (let w = 0; w < p; w++)
|
|
188
|
+
d[w] && d[w][a] && y.push(d[w][a]);
|
|
189
|
+
if (b)
|
|
190
|
+
for (let w = 0; w < a; w++)
|
|
191
|
+
d[p] && d[p][w] && y.push(d[p][w]);
|
|
192
|
+
return y.join(" ");
|
|
193
|
+
};
|
|
194
|
+
return o.forEach((p, a) => {
|
|
195
|
+
p.forEach((b, f) => {
|
|
196
|
+
const y = l.nodeAt(b);
|
|
197
|
+
if (y) {
|
|
198
|
+
const w = f < t.headerColumns, E = a < t.headerRows, C = { ...y.attrs };
|
|
199
|
+
I(y, C), C.headers = null, C.scope = null, E || w ? (t.associateHeaders === "scope" && (C.scope = E ? "col" : "row"), t.associateHeaders === "id" && (C.id = g(a, f), (f > 0 || a > 0) && (C.headers = m(a, f, w, E) || null)), s = H(s, y, i + b + 1, r, C)) : (t.associateHeaders === "id" && (C.headers = m(a, f, t.headerColumns > 0, t.headerRows > 0) || null), s = H(s, y, i + b + 1, c, C));
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}), s;
|
|
203
|
+
}, te = (n, t, i, l) => {
|
|
204
|
+
let e = { ...t.attrs };
|
|
205
|
+
return e = h(e, "margin-left", ""), e = h(e, "margin-right", ""), Object.keys(l || {}).forEach((o) => {
|
|
206
|
+
e = h(e, o, (l || {})[o] || "");
|
|
207
|
+
}), n.apply(n.tr.setNodeMarkup(i, null, e));
|
|
208
|
+
}, v = (n, t) => J("<p>" + n + "</p>", t).content.firstChild.content, M = (n, t) => {
|
|
209
|
+
if (!n.caption)
|
|
210
|
+
return;
|
|
211
|
+
let i = { caption: "", style: "display: table-caption" };
|
|
212
|
+
n.captionAlignment && (i = h(i, "text-align", n.captionAlignment)), n.captionPosition && (i = h(i, "caption-side", n.captionPosition));
|
|
213
|
+
const l = v(n.caption, t);
|
|
214
|
+
return l && t.nodes.table_caption_external.createAndFill(i, l) || void 0;
|
|
215
|
+
}, D = (n) => n.firstChild && n.firstChild.type.name === "table_caption_external", ne = (n, t, i, l) => {
|
|
216
|
+
let e = n, o;
|
|
217
|
+
const s = i + 2, r = i + 1, c = e.schema;
|
|
218
|
+
if (D(t))
|
|
219
|
+
if (o = t.firstChild, l.caption) {
|
|
220
|
+
const u = v(l.caption, c);
|
|
221
|
+
if (e = e.apply(
|
|
222
|
+
e.tr.replaceWith(s, s + o.content.size, u)
|
|
223
|
+
), o = e.doc.nodeAt(r), o) {
|
|
224
|
+
let d = { ...o.attrs };
|
|
225
|
+
d = h(d, "text-align", l.captionAlignment || ""), d = h(d, "caption-side", l.captionPosition || ""), e = e.apply(e.tr.setNodeAttribute(r, "style", d.style));
|
|
226
|
+
}
|
|
227
|
+
} else
|
|
228
|
+
e = e.apply(e.tr.deleteRange(s, s + o.content.size));
|
|
229
|
+
else
|
|
230
|
+
o = M(l, c), o && (e = e.apply(e.tr.replaceWith(r, r, o)));
|
|
231
|
+
return e;
|
|
232
|
+
}, oe = (n, t, i, l, e) => {
|
|
233
|
+
let o = {
|
|
234
|
+
state: n,
|
|
235
|
+
pos: i
|
|
236
|
+
};
|
|
237
|
+
if (!l && (t.position || t.caption)) {
|
|
238
|
+
let r = { table: "", style: "display: table" };
|
|
239
|
+
const c = [], u = t.position, d = u && k[u];
|
|
240
|
+
d && Object.keys(d).forEach((a) => {
|
|
241
|
+
r = h(r, a, d[a] || "");
|
|
242
|
+
}), typeof t.width == "number" && t.widthUnit === "%" && (r = h(r, "width", t.width + t.widthUnit));
|
|
243
|
+
const g = M(t, n.schema);
|
|
244
|
+
g && c.push(g);
|
|
245
|
+
const m = n.doc.nodeAt(i);
|
|
246
|
+
c.push(m);
|
|
247
|
+
const p = n.schema.nodes.table_wrapper.createAndFill(r, c);
|
|
248
|
+
if (p) {
|
|
249
|
+
const a = n.tr.replaceWith(i, i + m.content.size, p);
|
|
250
|
+
n = n.apply(a), o = { state: n, pos: i };
|
|
251
|
+
}
|
|
252
|
+
} else
|
|
253
|
+
l && (t.position || t.caption || !t.caption && D(l.node)) ? (n = te(n, l.node, e, t.position && k[t.position]), n = ne(n, l.node, e, t), o = { state: n, pos: e }) : l && !(t.position || t.caption) ? o = { state: n, node: l.node, pos: n.selection.$from.start(l.depth) - 1 } : o = { state: n, pos: i };
|
|
254
|
+
const s = l && o.state.doc.nodeAt(e);
|
|
255
|
+
if (s) {
|
|
256
|
+
let r;
|
|
257
|
+
typeof t.width == "number" && t.widthUnit === "%" ? r = h(s.attrs, "width", t.width + t.widthUnit) : t.widthUnit !== "%" && /%/.test(S(s.attrs.style || "").width || "") && (r = h(s.attrs, "width", "")), r && (o.state = o.state.apply(o.state.tr.setNodeMarkup(e, null, r)));
|
|
258
|
+
}
|
|
259
|
+
return o;
|
|
260
|
+
}, de = (n, t) => {
|
|
261
|
+
const i = n.selection.$from;
|
|
262
|
+
let l = T(i, (f) => f.type.spec.tableRole === "table");
|
|
263
|
+
if (!l)
|
|
264
|
+
return;
|
|
265
|
+
const e = i.start(l.depth) - 1;
|
|
266
|
+
let o = Z(n, e, t.rows, t.columns);
|
|
267
|
+
if (!o)
|
|
268
|
+
return;
|
|
269
|
+
const s = o.tr;
|
|
270
|
+
Q(o).forEach((f) => {
|
|
271
|
+
let y = { ...f.node.attrs };
|
|
272
|
+
y = h(y, "padding", typeof t.cellPadding == "number" ? t.cellPadding + "px" : ""), s.setNodeMarkup(f.pos, null, y);
|
|
273
|
+
}), o = o.apply(s), o = W(o, t, e), o = ee(o, t, e);
|
|
274
|
+
const r = T(i, (f) => f.type.name === "table_wrapper"), c = i.start((r == null ? void 0 : r.depth) || 0) - 1;
|
|
275
|
+
let u = oe(o, t, e, r, c);
|
|
276
|
+
o = u.state;
|
|
277
|
+
const d = u.pos, g = o.doc.nodeAt(u.pos);
|
|
278
|
+
if (!g)
|
|
279
|
+
return;
|
|
280
|
+
const m = d + (r || l).node.content.size, p = n.tr.replaceWith(d, m, g), a = O.atEnd(g), b = B.create(p.doc, d + a.to + 1);
|
|
281
|
+
return p.setSelection(b), p;
|
|
282
|
+
};
|
|
283
|
+
export {
|
|
284
|
+
de as applyTableData,
|
|
285
|
+
N as initialTableData,
|
|
286
|
+
ce as tableDefaultData,
|
|
287
|
+
k as tablePositionStyles
|
|
288
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@progress/kendo-editor-common"),i=require("../utils.js"),d=/[\D]+$/,f=e=>{const t=e.match(d);return t?t[0]:""},b=(e,t)=>{var n;const s=u(((n=e.attrs)==null?void 0:n.style)||"")[t]||"";return{[t]:parseFloat(s)||null,[t+"Unit"]:f(s)}},u=e=>(e||"").split(/\s*;\s*/).filter(Boolean).map(s=>{const n=s.split(/\s*:\s*/);return{[n[0]]:n[1]}}).reduce((s,n)=>({...s,...n}),{}),m=(e,t)=>{const s=t.style,n=t.value,l=t.newValue;if(!e)return{changed:!1,style:null};const o=e.split(/\s*;\s*/).filter(r=>!!r),c=o.filter(r=>{const a=r.split(/\s*:\s*/);return!(a[0].toLowerCase()===s&&n.test(a[1]))});return l&&c.push(`${s}: ${l}`),{style:c.join("; ")+(c.length?";":""),changed:!!l||c.length!==o.length}},g=/^.+$/;function $(e,t,s){let n;if(new RegExp("[^-]?"+t+":").test(e.style||"")){const{style:l}=m(e.style||"",{style:t,value:g,newValue:s});n={...e,style:l}}else if(e.style){const l=u(e.style);l[t]=s,n={...e,style:Object.keys(l).filter(o=>!!l[o]).reduce((o,c)=>o+c+": "+l[c]+"; ","").trim()}}else s?n={...e,style:t+": "+s+";"}:n={...e};return n}const N=e=>{const{doc:t,selection:s}=e,n=[];return s.ranges.forEach(l=>{const o=l.$from.pos,c=l.$to.pos;t.nodesBetween(o,c,(r,a,p,S)=>{(r.type.name==="table_cell"||r.type.name==="table_header")&&n.push({node:r,pos:a})})}),n},h=e=>{const t=i.parentNode(e.selection.$from,n=>n.type.name==="table"),s=i.parentNode(e.selection.$to,n=>n.type.name==="table");return t&&s&&t.depth===s.depth&&t.node.eq(s.node)?N(e).filter(({pos:l})=>{const o=i.parentNode(e.doc.resolve(l),c=>c.type.name==="table");return o&&o.depth===t.depth&&t.node.eq(o.node)}):[]},C=e=>{const t=[];if(h(e).length){const s=e.selection.$from,n=i.parentNode(s,a=>a.type.spec.tableRole==="table");if(n===null)return t;const l=s.start(n.depth),o=n.node,c=y.TableMap.get(o),r=e.doc;c.map.forEach(a=>{const p=a+l;t.push({pos:p,node:r.nodeAt(p)})})}return t};exports.getUnit=f;exports.nodeSize=b;exports.parseStyle=u;exports.reUnit=d;exports.selectedCells=h;exports.setNodeStyle=$;exports.tableCells=C;
|