@sofereditor/react 0.3.0 → 0.3.2
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 +44 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +44 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -2173,6 +2173,13 @@ function fragmentClass(f) {
|
|
|
2173
2173
|
function alignClass(a) {
|
|
2174
2174
|
return a ? ` ed-align-${a}` : "";
|
|
2175
2175
|
}
|
|
2176
|
+
function cellStyle(attrs) {
|
|
2177
|
+
if (!attrs) return void 0;
|
|
2178
|
+
const style = {};
|
|
2179
|
+
if (attrs.align) style.textAlign = attrs.align;
|
|
2180
|
+
if (attrs.bgColor) style.backgroundColor = attrs.bgColor;
|
|
2181
|
+
return Object.keys(style).length > 0 ? style : void 0;
|
|
2182
|
+
}
|
|
2176
2183
|
function clampLevel(l) {
|
|
2177
2184
|
if (l === 2 || l === 3 || l === 4 || l === 5 || l === 6) return l;
|
|
2178
2185
|
return 1;
|
|
@@ -2226,7 +2233,7 @@ function TableView({ block, index, tableFragment }) {
|
|
|
2226
2233
|
"data-cell-colspan": colspan,
|
|
2227
2234
|
rowSpan: rowspan > 1 ? rowspan : void 0,
|
|
2228
2235
|
colSpan: colspan > 1 ? colspan : void 0,
|
|
2229
|
-
style: cell?.attrs
|
|
2236
|
+
style: cellStyle(cell?.attrs),
|
|
2230
2237
|
className: inRect ? "ed-cell ed-cell--selected" : "ed-cell",
|
|
2231
2238
|
children: renderInline(delta, `t${index}-c${flat}`)
|
|
2232
2239
|
},
|
|
@@ -3001,6 +3008,14 @@ function useEditor(opts = {}) {
|
|
|
3001
3008
|
}
|
|
3002
3009
|
return getBlockAttr("align");
|
|
3003
3010
|
}, [doc, getBlockAttr]);
|
|
3011
|
+
const setCellBackground = (0, import_react13.useCallback)((color) => {
|
|
3012
|
+
(0, import_core5.setCellAttr)(ctxRef.current, "bgColor", color);
|
|
3013
|
+
}, []);
|
|
3014
|
+
const getCellBackground = (0, import_react13.useCallback)(() => {
|
|
3015
|
+
const sel = selectionRef.current;
|
|
3016
|
+
if (sel.focus.cellIndex == null || !doc.isTable(sel.focus.blockIndex)) return void 0;
|
|
3017
|
+
return doc.getCellAttrs(sel.focus.blockIndex, sel.focus.cellIndex).bgColor;
|
|
3018
|
+
}, [doc]);
|
|
3004
3019
|
const isListActive = (0, import_react13.useCallback)(
|
|
3005
3020
|
(kind) => {
|
|
3006
3021
|
const sel = selectionRef.current;
|
|
@@ -3240,6 +3255,8 @@ function useEditor(opts = {}) {
|
|
|
3240
3255
|
setBlockAttr,
|
|
3241
3256
|
setAlign,
|
|
3242
3257
|
getAlign,
|
|
3258
|
+
setCellBackground,
|
|
3259
|
+
getCellBackground,
|
|
3243
3260
|
isListActive,
|
|
3244
3261
|
toggleList,
|
|
3245
3262
|
indentList,
|
|
@@ -4714,6 +4731,32 @@ function TableMenu() {
|
|
|
4714
4731
|
setOpen(false);
|
|
4715
4732
|
editor.splitCell();
|
|
4716
4733
|
}, children: "Dividir c\xE9lulas mescladas" }),
|
|
4734
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("hr", {}),
|
|
4735
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "ed-toolbar-label ed-table-bgcolor", children: [
|
|
4736
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
4737
|
+
"span",
|
|
4738
|
+
{
|
|
4739
|
+
className: "ed-toolbar-swatch",
|
|
4740
|
+
"aria-hidden": true,
|
|
4741
|
+
style: { background: editor.getCellBackground() ?? "#ffffff" }
|
|
4742
|
+
}
|
|
4743
|
+
),
|
|
4744
|
+
"Cor de fundo da c\xE9lula",
|
|
4745
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
4746
|
+
"input",
|
|
4747
|
+
{
|
|
4748
|
+
type: "color",
|
|
4749
|
+
value: editor.getCellBackground() ?? "#ffffff",
|
|
4750
|
+
onChange: (e) => editor.setCellBackground(e.target.value),
|
|
4751
|
+
"aria-label": "Cor de fundo da c\xE9lula"
|
|
4752
|
+
}
|
|
4753
|
+
)
|
|
4754
|
+
] }),
|
|
4755
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", onClick: () => {
|
|
4756
|
+
setOpen(false);
|
|
4757
|
+
editor.setCellBackground(null);
|
|
4758
|
+
}, children: "Remover cor de fundo" }),
|
|
4759
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("hr", {}),
|
|
4717
4760
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
4718
4761
|
"button",
|
|
4719
4762
|
{
|