@sofereditor/react 0.10.0 → 0.10.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/dist/index.cjs CHANGED
@@ -3134,6 +3134,12 @@ function sliceDelta(delta, start, end) {
3134
3134
  var import_react10 = require("react");
3135
3135
  var import_core7 = require("@sofereditor/core");
3136
3136
  var import_jsx_runtime11 = require("react/jsx-runtime");
3137
+ function posicaoVisualDaDivisa(xLogico, larguraPx, rtl) {
3138
+ return rtl ? larguraPx - xLogico : xLogico;
3139
+ }
3140
+ function sinalDoArrasto(rtl) {
3141
+ return rtl ? -1 : 1;
3142
+ }
3137
3143
  function deltaPctDoArrasto(dxPx, larguraTabelaPx) {
3138
3144
  if (!(larguraTabelaPx > 0)) return 0;
3139
3145
  return dxPx / larguraTabelaPx * 100;
@@ -3143,7 +3149,7 @@ function distribuirAltura(base, deltaPx) {
3143
3149
  const fatia = deltaPx / base.length;
3144
3150
  return base.map((h) => Math.max(import_core7.MIN_LINHA_PX, Math.round(h + fatia)));
3145
3151
  }
3146
- function TableResizeOverlay({ tableRef, blockIndex, cols, rows }) {
3152
+ function TableResizeOverlay({ tableRef, blockIndex, cols, rows, rtl = false }) {
3147
3153
  const editor = useEditorContext();
3148
3154
  const [layout, setLayout] = (0, import_react10.useState)(null);
3149
3155
  const arrastoRef = (0, import_react10.useRef)(null);
@@ -3218,7 +3224,8 @@ function TableResizeOverlay({ tableRef, blockIndex, cols, rows }) {
3218
3224
  if (!d) return;
3219
3225
  switch (d.tipo) {
3220
3226
  case "coluna": {
3221
- const dPct = deltaPctDoArrasto(e.clientX - d.startX, d.tableWidthPx);
3227
+ const dx = (e.clientX - d.startX) * sinalDoArrasto(rtl);
3228
+ const dPct = deltaPctDoArrasto(dx, d.tableWidthPx);
3222
3229
  editor.setColumnBoundary(blockIndex, d.boundary, dPct, d.baseWidths);
3223
3230
  break;
3224
3231
  }
@@ -3243,7 +3250,7 @@ function TableResizeOverlay({ tableRef, blockIndex, cols, rows }) {
3243
3250
  }
3244
3251
  }
3245
3252
  },
3246
- [blockIndex, editor]
3253
+ [blockIndex, editor, rtl]
3247
3254
  );
3248
3255
  const containerWidthPxOf = (0, import_react10.useCallback)((table, tableWidthPx) => {
3249
3256
  return table.parentElement?.getBoundingClientRect().width || tableWidthPx;
@@ -3359,7 +3366,7 @@ function TableResizeOverlay({ tableRef, blockIndex, cols, rows }) {
3359
3366
  {
3360
3367
  contentEditable: false,
3361
3368
  className: "ed-col-resize-handle",
3362
- style: colHandleStyle(x),
3369
+ style: colHandleStyle(posicaoVisualDaDivisa(x, layout.width, rtl)),
3363
3370
  onPointerDown: onColumnPointerDown(c),
3364
3371
  onPointerMove,
3365
3372
  onPointerUp,
@@ -3577,6 +3584,7 @@ function TableView({ block, index, tableFragment }) {
3577
3584
  ref: tableRef,
3578
3585
  "data-block-index": index,
3579
3586
  "data-block-type": "table",
3587
+ dir: block.attrs.dir === "rtl" || block.attrs.dir === "ltr" ? block.attrs.dir : void 0,
3580
3588
  className: "ed-block ed-table",
3581
3589
  style: typeof tableWidth === "number" ? { width: `${tableWidth}%` } : void 0,
3582
3590
  children: [
@@ -3630,7 +3638,16 @@ function TableView({ block, index, tableFragment }) {
3630
3638
  ]
3631
3639
  }
3632
3640
  ),
3633
- isFirstFragment && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableResizeOverlay, { tableRef, blockIndex: index, cols, rows })
3641
+ isFirstFragment && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3642
+ TableResizeOverlay,
3643
+ {
3644
+ tableRef,
3645
+ blockIndex: index,
3646
+ cols,
3647
+ rows,
3648
+ rtl: block.attrs.dir === "rtl"
3649
+ }
3650
+ )
3634
3651
  ] });
3635
3652
  }
3636
3653
  function spanAttr(v) {